Write tool corrupts UTF-8 multi-byte characters (box-drawing chars become NULL bytes)

Status Closed — not planned
Maintainer reply None cached
Activity 6 comments · opened Dec 4, 2025 · closed Feb 12, 2026

Summary

The Write tool corrupts UTF-8 multi-byte characters by stripping the high bytes, leaving only the low byte of each Unicode codepoint. This results in files that appear as "binary" and cannot be opened in text editors.

Environment

  • OS: Linux 6.17.0-7-generic
  • Claude Code: VS Code extension

Steps to Reproduce

  1. Ask Claude to write a file containing Unicode box-drawing characters:

``
Write a markdown file with box-drawing characters like ─ │ ┌ ┐ └ ┘
``

  1. Try to open the resulting file in VS Code, bat, micro, or other text editors
  1. Editors report the file is binary or has unsupported encoding

Expected Behavior

Box-drawing character ─ (U+2500) should be encoded as 3-byte UTF-8: e2 94 80

Actual Behavior

The character is written as a single byte 00 (just the low byte of the codepoint)

Hex dump comparison:

Corrupted file (written by Write tool):

7c 20 60 00       60 20 7c   →  | `.` |   (NULL byte!)
         ^^ ^^ ^^

Correct file (copy-pasted from Claude's stdout):

7c 20 60 e2 94 80 60 20 7c   →  | `─` |   (proper UTF-8)
         ^^ ^^ ^^

Pattern

The corruption consistently strips UTF-8 encoding, keeping only codepoint & 0xFF:

| Character | Unicode | Expected UTF-8 | Actual Byte |
|-----------|---------|----------------|-------------|
| ─ | U+2500 | e2 94 80 | 00 |
| │ | U+2502 | e2 94 82 | 02 |
| ┌ | U+250C | e2 94 8c | 0c |
| ┐ | U+2510 | e2 94 90 | 10 |
| └ | U+2514 | e2 94 94 | 14 |
| ┘ | U+2518 | e2 94 98 | 18 |

Workaround

Copy-paste Claude's stdout output to a file manually instead of using the Write tool.

Impact

  • Files containing emoji, CJK characters, box-drawing, or any non-ASCII Unicode will be corrupted
  • Affected files cannot be opened in standard text editors
  • No warning is given that corruption occurred

View original on GitHub ↗

6 Comments

github-actions[bot] · 10 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/6903
  2. https://github.com/anthropics/claude-code/issues/1716
  3. https://github.com/anthropics/claude-code/issues/7558

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

scpedicini · 10 months ago

Experiencing this issue as well. This corruption resulting in weird control chars / null bytes also started happening VERY consistently whenever Claude edits an empty markdown file.

github-actions[bot] · 9 months ago

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

xrchz · 9 months ago

This issue is part of a larger UTF-8/encoding bug pattern affecting Claude Code's Edit/Write tools.

I've posted a consolidated impact analysis at #13939 showing at least 6+ related issues spanning 6+ months. The technical analysis you provided here (showing codepoint & 0xFF truncation) is particularly valuable for debugging.

Cross-linking for visibility: #13939, #7134, #7332, #7335

This affects all non-English users and should be prioritized.

---
🤖 Generated with Claude Code

github-actions[bot] · 8 months ago

This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.

github-actions[bot] · 7 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.