Edit tool replaces Turkish UTF-8 characters with ASCII equivalents
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
When using the Edit tool to modify files containing Turkish UTF-8 characters, Claude Code systematically replaces Turkish special characters with their ASCII equivalents:
- ş → s
- ı → i
- ğ → g
- ü → u
- ö → o
- ç → c
- Ş → S
- İ → I
- Ğ → G
- Ü → U
- Ö → O
- Ç → C
This happens both when:
- Adding new content that contains Turkish characters
- When the edit touches existing Turkish text in the file
The corruption occurs silently without any warning, causing data loss and requiring manual fixes.
What Should Happen?
Claude Code should preserve all UTF-8 characters exactly as they appear in the source content. Turkish characters (and other non-ASCII Unicode characters) should remain unchanged when:
- Reading files with Turkish content
- Editing files that contain Turkish characters
- Writing new content that includes Turkish characters
The Edit tool should be encoding-aware and maintain byte-for-byte accuracy for all UTF-8 content.
Error Messages/Logs
Steps to Reproduce
- Create a file with Turkish content:
``typescript``
// test.ts
const message = 'Merhaba dünya! Türkçe karakterler: şğüöçı'
- Ask Claude to edit the file (e.g., "add a console.log statement"):
````
claude "Add a console.log to print the message in test.ts"
- After the edit, check the file content:
``typescript``
// Result - Turkish characters are corrupted:
const message = 'Merhaba dunya! Turkce karakterler: sguoci'
Real-world example from my session:
- Original file had:
'PWA (Progressive Web App) özellikleri kapsamlı şekilde geliştirildi' - After Claude's edit:
'PWA (Progressive Web App) ozellikleri kapsamli sekilde gelistirildi'
The issue is 100% reproducible with any file containing Turkish characters.
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.0.69 (Claude Code)
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
VS Code integrated terminal
Additional Information
Impact
This bug affects all non-English languages that use special UTF-8 characters, including but not limited to:
- Turkish (ş, ğ, ı, ü, ö, ç)
- German (ä, ö, ü, ß)
- French (é, è, ê, ë, à, ç)
- Spanish (ñ, á, é, í, ó, ú)
- Portuguese, Polish, Czech, and many others
Workaround
Currently, users must manually review and fix all edited files after each Claude Code operation, which is time-consuming and error-prone.
Hypothesis
The issue may be related to:
- Character encoding during file read/write operations
- Internal string normalization that converts to ASCII
- A tokenization or processing step that strips non-ASCII characters
Notes
- The bug is 100% reproducible
- Affects both the Edit and Write tools
- Happens regardless of file type (.ts, .tsx, .js, .json, .md, etc.)
- File encoding is UTF-8 with proper BOM
11 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
This is also broken for Unicode quotes (‘, ’, “, ”) being replaced by ASCII quotes (', ").
Such a capable model held back by such garbage software.
I should note I am using GNU/Linux - this is not just a Windows issue.
Consolidated Impact Analysis - This Needs Priority Attention
I've analyzed this issue along with at least 6 related open issues that all stem from the same root cause: Claude Code's Edit/Write tools have fundamental UTF-8 encoding bugs.
Related Issues (All Still Open/Affecting Users)
| Issue | Description | Status |
|-------|-------------|--------|
| #13939 | Turkish UTF-8 characters → ASCII | Open |
| #13080 | UTF-8 multi-byte chars → NULL bytes | Open |
| #7134 | Windows-1252 encoding corruption | Open |
| #7332 | Chinese characters garbled | Open |
| #7335 | Swedish å,ä,ö → replacement char | Recently closed (inactivity, not fixed) |
| #6246, #5518, #3416 | Earlier duplicates | Various |
Why This Is High Priority
Technical Pattern Identified
From #13080's excellent analysis, the bug appears to be truncating UTF-8 multi-byte sequences to single bytes:
─(U+2500) should bee2 94 80(3 bytes)00(justcodepoint & 0xFF)This suggests the encoding pipeline is treating Unicode codepoints as single bytes somewhere in the Write/Edit implementation.
Request
Could this be escalated internally? The volume of duplicate issues (spanning 6+ months) and the fundamental nature of the bug suggest this deserves engineering attention before more features are added.
cc @dicksontsai (who acknowledged this pattern in #7335)
---
🤖 Generated with Claude Code
Root Cause Analysis: The Problem is Deeper Than the Edit Tool
I have been debugging this issue systematically and found that the corruption happens at the model generation level, not in the Edit/Write tool implementation.
Experiment
I tested by having Claude write a file with explicit Unicode quote characters. When Claude tries to write:
The actual bytes written are all ASCII 0x27, not Unicode U+2018/U+2019.
Tracing the Code Path
I examined the pi-coding-agent infrastructure (which uses the same Anthropic SDK):
fsWriteFile(path, content, "utf-8")- passes content through unchangedJSON.parseConclusion
The model itself cannot generate Unicode curly quotes in tool call parameters. When Claude generates what appears to be curly-quoted text, the actual tokens produced are ASCII apostrophes (0x27), not Unicode LEFT/RIGHT SINGLE QUOTATION MARKs (U+2018/U+2019).
This is a tokenization or generation constraint at the Anthropic model level, not a bug in Claude Code's Edit/Write implementation. The infrastructure faithfully writes exactly what the model generates - but the model generates ASCII where Unicode was intended.
Workaround
Use bash with explicit hex escapes:
Implications
This suggests the fix needs to happen in:
The Edit/Write tool code appears correct - it is faithfully transmitting what the model produces.
This does not only effect non-English users. We have a lot of code with typographic quotation marks, e.g. the line
``
log.error(s"$link specifies StudyOID “$oid”. Cannot find it in database.")``gets transformed into
``
log.error(s"$link specifies StudyOID "$oid". Cannot find it in database.")``breaking the code (does not compile). When I tell the agent, the straight quotation marks just get escaped. The code works again but the output does not look as intended.
After many loops of "sorry, but my edit tool cannot tell the difference" and trying various workarounds, I finally get the result. But each time (context window) I start from scratch. Please fix this.
Just to add here another "me too". I have suffered from this kind of corruptions since day one of using Clade Code. And even with precise instructions to workaround this (for instance, using some script to convert from ANSI to UTF8 before editing the files) Claude some times forgots to do this. And fixing this errors as some other users have said costs tokens or a lot of time to fix something that was not broken on the first place.
Anthropic confirmed to me - after much delay and hoop jumping - when I had Priority support that they have no intention of prioritising this issue. I cancelled my subscription and encourage everyone to do the same.
Closing for now — inactive for too long. Please open a new issue if this is still relevant.
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.