Write tool silently converts full-width CJK punctuation to half-width ASCII when overwriting files

Resolved 💬 7 comments Opened Apr 20, 2026 by kiki830621 Closed Jul 5, 2026

Summary

When the Write tool overwrites a file containing full-width CJK punctuation
(,。:;?!()), those characters are silently
converted to their half-width ASCII equivalents (,, ., :, ;, ?, !, (, )).

This is a silent corruption — no error is raised. It is especially destructive
for Chinese / Japanese / Korean technical writing, LaTeX documents, and typography-sensitive
content where the distinction between full-width and half-width is semantically meaningful.

Reproduction

  1. Create a file test.md containing full-width CJK punctuation, e.g.:

``
你好,世界。(這是測試):「引號」
``

That is: 你好,世界。(這是測試):「引號」

  1. Have Claude Code Read the file, then Write back the exact same content.
  1. Inspect the file. The full-width punctuation has been replaced with half-width ASCII:

``
你好,世界.(這是測試):「引號」
``

Expected

Content written via Write should be byte-for-byte identical to the string passed
by the agent. Full-width Unicode characters must be preserved verbatim.

Actual

Silent replacement. Observed mappings:

| Original | Codepoint | Converted | Codepoint |
|----------|-----------|-----------|-----------|
| | U+FF0C | , | U+002C |
| | U+3002 | . | U+002E |
| | U+FF1A | : | U+003A |
| | U+FF1B | ; | U+003B |
| | U+FF1F | ? | U+003F |
| | U+FF01 | ! | U+0021 |
| | U+FF08 | ( | U+0028 |
| | U+FF09 | ) | U+0029 |

Full-width CJK quote marks (「」『』) appear to be unaffected.

Related: Edit tool shows the same normalization

The Edit tool has a related failure mode. When old_string is a literal string
containing full-width punctuation, the match silently fails with
String to replace not found in file. Testing suggests the agent's input is being
normalized to half-width before comparison against the actual file bytes, so the
agent cannot even produce an old_string that matches an existing full-width
punctuation mark in the file.

Impact

  • Silent data corruption in CJK technical documents, LaTeX lecture notes,

research manuscripts, and other typography-sensitive writing.

  • Damage is invisible until the document is compiled or rendered.
  • Recovery requires one of: git rollback (if the file was tracked), backup

restoration, or a custom Python script that performs contextual half-width
to full-width repair based on CJK adjacency.

  • I have hit this repeatedly across multiple sessions, which is what motivated

this report.

Workaround

Avoid the Write tool when rewriting files that contain full-width CJK
punctuation. Options that preserve the characters correctly:

  1. Bash + a Python heredoc. Python writes the bytes literally:

``bash
python3 << 'PYEOF'
content = "..." # full content with full-width punctuation
with open(path, 'w', encoding='utf-8') as f:
f.write(content)
PYEOF
``

  1. Edit with old_string / new_string boundaries anchored to ASCII

characters only (avoid full-width boundaries, since the input appears to be
normalized before matching).

Environment

  • Platform: macOS (Darwin 25.4.0)
  • Claude Code: latest release as of 2026-04-20
  • Model: Opus 4.7 (1M context)

View original on GitHub ↗

This issue has 7 comments on GitHub. Read the full discussion on GitHub ↗