[BUG] UTF-8 Corruption Bug
Environment
- Platform (select one):
- [ ] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [X] Other: Anthropic Max subscription
- Claude CLI version: 1.0.16 (Claude Code)
- Operating System: Archlinux Linux 6.14.7-arch2-1 x86_64
- Terminal: Konsole
- Python: 3.13.3
- Locale: en_US.UTF-8 (properly configured)
- Tool: Claude Code Write tool
Bug Description
The Claude Code Write tool that causes Unicode corruption, resulting in data loss for non-English content. This issue affects file operations and impacts user workflows sometimes.
Problem Summary
The Write tool occasionally corrupts Unicode characters when creating files, specifically:
- Russian Cyrillic text becomes unreadable gibberish (Dialog-First ?>4E>4** - 15+ ?0BB5@=>2 B@8335@>2 4;O 02B><0B8G5A:>3> >1=0@C65=8O 206=>9 8=D>@<0F88)
- Emoji are replaced with control characters
- English text remains unaffected
- Issue occurs "time to time" (intermittent but recurring)
Impact
This bug causes actual data corruption requiring manual file recovery. For users working with non-English content, this represents a significant reliability issue that affects productivity and trust in the tool.
Technical Details
I have prepared a comprehensive bug report with:
- Complete system environment details
- Technical analysis of the corruption pattern
- File examples (corrupted vs corrected)
- Hex dumps and encoding analysis
- Reproduction information
- Root cause hypothesis
The evidence suggests UTF-8 bytes are being incorrectly interpreted as CP1251/Windows-1251 encoding during file write operations, likely due to a race condition or intermittent encoding handling bug.
Steps to Reproduce
- Using Write() utility when writing non-Cyrillic characters (very rare)
Expected Behavior
- 🔍 Dialog-First подход - 15+ паттернов триггеров для автоматического обнаружения важной информации
- 🔄 Smart Update логика - интеллектуальная обработка изменений (ADD, UPDATE, DELETE, MERGE)
- 🗣️ Natural Language навигация - естественное взаимодействие ("покажи вчерашнее обсуждение")
Actual Behavior
- **=
Dialog-First ?>4E>4** - 15+ ?0BB5@=>2 B@8335@>2 4;O 02B><0B8G5A:>3> >1=0@C65=8O 206=>9 8=D>@<0F88
- =^D Smart Update ;>38:0 - 8=B5;;5:BC0;L=0O >1@01>B:0 87<5=5=89 (ADD, UPDATE, DELETE, MERGE)
- =ã^O Natural Language =02830F8O - 5AB5AB25==>5 2708<>459AB285 ("?>:068 2G5@0H=55 >1AC645=85")
Additional Context
Important! Claude Code is able to fix this error on his own if he sees that something is written incorrectly in the file. But once he suspended the work saying that I was violating the rules of using the application, stating as a reason that I was allegedly trying to exploit vulnerabilities (lol)
report_unicode.md - detailed description
README.md
README_corrupted.md
16 Comments
Yeah. This also happens to me when generating .md files
ping
!Image
<img width="766" height="537" alt="Image" src="https://github.com/user-attachments/assets/53db378c-1ca9-4d88-b084-17c2997bbcb2" />
🗿
<img width="821" height="1138" alt="Image" src="https://github.com/user-attachments/assets/46e85531-2b01-46a4-bbda-acfa338bd9c7" />
Same problem:
<img width="564" height="168" alt="Image" src="https://github.com/user-attachments/assets/b2d03446-de62-47e0-b4aa-840d221a5b21" />
Even more, in the same file might be half OK, half BAD.
Only one solution is to ask CC to fix it. And it sees the wrong symbols.
Happens mostly in VSCode extension rather than in cli
I've noticed this in just normal
claude.aiweb chat with Sonnet 4.5 - It misinterprets anéforéfor example.I uploaded a valid UTF-8 file to claude.ai (Sonnet 4.5) and asked it to check grammar. Instead Claude complained about gibberish due to it bungling the encoding. E.g. it reported '"lot’s" - Should be "lot's" (incorrect apostrophe encoding)'.
Claude webapp wrote a bunch of emojis in a file and then can't even read them back in. Is Claude unable to consume Claude's content? Is UTF-8 not the default everywhere?
The Claude assistant integrated into Cursor is corrupting files with ANSI encoding (Windows-1252 or similar) during edits. Even when the original file is in ANSI, Claude forces saving in UTF-8, resulting in:
Replacement of accented characters (e.g., ç, ã, õ, á, é) with mojibake or black boxes (�).
Irreversible data loss in legacy files (e.g., old systems, .bat, .vbs, .ini scripts).
Inconsistent and non-configurable behavior — it does not respect the original encoding.
Claude Code 2.0.36
It corrupts the data and then look at this as an "appears to violate our Usage Policy". LOL
Encountered a variant of this bug where the Write tool injected 26 null bytes when writing Unicode arrow characters (→,
U+2192) to a new README.md file. The null bytes were scattered throughout the file, not just near the corrupted characters.
Result:
Verification:
Same happens when you upload a file in an online project through the web GUI.
Bug Report: Box-Drawing Character Corruption in Markdown Output
## Summary
Claude Code occasionally outputs ASCII box-drawing diagrams that get corrupted into null byte sequences, rendering them unreadable in the final markdown file.
## Environment
## Reproduction
When Claude Code generates ASCII box diagrams (like architectural flowcharts or data structure visualizations), the box-drawing characters get replaced with null bytes and
sentinel characters.
Expected Output:
┌───────────────────────────────────────┐
│ BOOTSTRAP (runs once at startup) │
├───────────────────────────────────────┤
│ 1. Pre-parse globals → Configure svcs │
└───────────────────────────────────────┘
Actual Output (hex view):
0c 00 00 00 00 00 00 ... 10 0a
02 20 42 4f 4f 54 53 54 52 41 50 ...
1c 00 00 00 00 00 00 ... 00 24
02 20 31 2e 20 50 72 65 2d 70 61 72 73 65 ...
## Character Mapping Discovered
| Hex Bytes | Intended Character | Description |
|-----------|-------------------|-------------|
|
0x02 0x0a|│\n| Vertical line + newline ||
0x02 0x20|│| Vertical line + space ||
0x00(repeated) |─| Horizontal line (variable length) ||
0x0c 0x00 0x00|┌| Top-left corner ||
0x10 0x0a|┐\n| Top-right corner + newline ||
0x1c 0x00 0x00|├| Left T-junction ||
0x00 0x24|┤| Right T-junction (null + dollar sign) ||
0x14 0x00|└| Bottom-left corner ||
0x18 0x0a|┘\n| Bottom-right corner + newline |## Additional Issues
0x00bytes result in misaligned right edges across different boxes0x24(ASCII `/feedback Regression in plan/markdown artifact output. Recently this has been happening consistently enough that we made aquick fix script.
) appears as a sentinel marker for right-edge characters, not as an actual dollar sign
## Impact
## Workaround
Created a repair script that maps null byte patterns back to proper UTF-8 box-drawing characters with width normalization:
/scripts/workspace/fix-markdown-nulls.tsThis 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.
I hit this constantly with CP1251 and CP1252 files. Built an MCP server in Go as a workaround. it auto-detects encoding and preserves it on writes instead of forcing UTF-8. Also adds a proper tree tool since the built-in one is missing on Windows.
https://github.com/dimitar-grigorov/mcp-file-tools
Won't fix the root cause, but keeps non-ASCII files intact right now.
The Unicode corruption you describe (Russian Cyrillic, among others) shares the same root cause as the curly quote normalization in Write/Edit. While the Cyrillic issue may have additional factors, the curly→straight normalization is a documented, intentional transformation that corrupts non-ASCII textual content.
A
/curlyoption has been proposed to address this class of problems with context-aware verification instead of blanket normalization.→ [FEATURE] /curly option: context-aware curly/straight character handling in Write/Edit — #31482