[BUG] support for non-UTF-8 file encodings (e.g., GB2312) to prevent file corruption
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 Claude Code to edit local files encoded in GB2312 (common in Chinese environments), the tool writes content back in UTF-8 without converting the existing encoding. This results in Chinese characters becoming garbled (mojibake) and corrupts the source files.
What Should Happen?
Claude Code should:
Automatically detect the file's encoding before reading/writing.
Or, provide a configuration option (e.g., in a .claudecodeconfig or via flag) to specify the project's default encoding.
Or, at least warn the user if the file is not UTF-8 encoded.
Error Messages/Logs
Steps to Reproduce
Open a project where source files are encoded in GB2312.
Ask Claude Code to modify a file containing Chinese characters.
Claude Code applies the edit.
Open the file in an editor; all Chinese characters are corrupted.
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
v2.1.79
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
PowerShell
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗