Edit tool corrupts multi-byte UTF-8 characters at replacement string boundary
Resolved 💬 3 comments Opened Apr 11, 2026 by r041367 Closed Apr 11, 2026
Description
The Edit tool occasionally corrupts multi-byte UTF-8 characters (e.g., CJK characters) when they appear in the new_string parameter. The last multi-byte character in a string gets truncated at a byte boundary, producing replacement characters (��).
Steps to Reproduce
- Use the Edit tool to replace text in a file containing CJK (Chinese/Japanese/Korean) characters
- Include multi-byte UTF-8 characters in the
new_stringparameter - The final multi-byte character in the replacement string may be truncated
Example
Expected new_string content:
**進行中**
Actual result written to file:
**進行��**
The character 中 (U+4E2D, 3-byte UTF-8 sequence E4 B8 AD) was truncated — only the first byte(s) were written, producing the replacement character U+FFFD (��).
Environment
- OS: macOS (Darwin 25.4.0)
- Model: claude-opus-4-6 (1M context)
- Tool: Edit (exact string replacement mode)
Impact
- Silently corrupts file content — no error is raised
- Particularly affects CJK languages where most characters are 3-byte UTF-8 sequences
- Requires manual detection and a follow-up commit to fix
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗