[BUG] Unicode corruption in Edit/Write payloads and written file content (U+FFFD / broken UTF-8)
Claude Code intermittently corrupts Unicode in the mutation-tool path.
This report is specifically about Edit / Write / related mutation payloads and written file content, not about assistant response text.
I have observed cases where structured tool payloads already contain broken Unicode, including U+FFFD and visibly broken multibyte sequences, and cases where the corrupted text is actually written into a file and later repaired by a follow-up Edit.
So this does not look like a terminal-display-only issue. It appears that Unicode is being corrupted somewhere in the tool input / serialization / file write path.
What Should Happen?
If the model emits valid Unicode, Claude Code should preserve it exactly through:
- tool input construction
- serialization / transport
- mutation-tool execution
- file writeback
It should never introduce:
U+FFFD- broken multibyte sequences
- silent Unicode degradation in written files
Error Messages/Logs
Observed examples from saved session logs:
Write/Edit payload examples:
- Japanese heading text became corrupted with U+FFFD
- Japanese prose in Markdown became corrupted with broken UTF-8 sequences
- A short CJK UI string was written as
��and later corrected to次
Concrete corrupted fragments observed:
技術���タックア��セスタスクワー��ー
Written-file readback example:
- Grep returned:
<span ...>��</span> - The very next Edit changed it to:
次
This suggests the corrupted text was actually written into the file.
Steps to Reproduce
This is intermittent, so I cannot provide a deterministic 100% repro yet, but the pattern is:
- Start Claude Code in a repo with files containing Japanese/CJK text.
- Ask Claude to create or edit files with Japanese text via
WriteorEdit. - Prefer longer sessions or sessions involving multiple edits/refinements.
- Inspect:
- the resulting file content
- any follow-up grep/readback output
- saved session logs under
~/.claude/projects
- In affected sessions, some tool payloads or written file content contain
U+FFFD/�or visibly broken UTF-8 sequences.
Examples of affected content:
- Japanese Markdown headings
- Japanese prose in docs
- short CJK UI strings such as
次
Additional Information
This issue is intentionally limited to the mutation-tool / file-write path.
I am separating it from the assistant-response-text corruption issue:
- #40396
Related issues:
- #26141
- #18422
- #6870
My current interpretation is:
- response-text corruption and mutation-tool corruption may be related
- but this report is specifically about corruption that already appears in
Edit/Writepayloads or in the resulting file content
I checked two local environments.
Environment A:
- observed in logs for
2.1.77,2.1.91,2.1.92
Environment B:
- scanned 4148 jsonl files under
~/.claude/projects - files containing
U+FFFD: 52 - strongest source candidates were
Edit,Write,Agent, andExitPlanModeinput payloads Readoften appeared downstream, but did not look like the primary source in the checked cases
Temporary mitigation:
For the mutation-tool path only, a PostToolUse hook for Write / Edit / MultiEdit can scan written files for UTF-8 EF BF BD and reject the tool result if found. This is useful as a workaround, but it does not mitigate assistant-response corruption.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗