claude-code - 💡(How to fix) Fix [BUG] Edit tool corrupts GBK-encoded Chinese comments in source files

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

Error Messages/Logs

RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

When using the Edit tool to modify a C++ source file that uses GBK/GB2312 encoding, the tool changes the file encoding and corrupts existing Chinese comments (they become garbled/unreadable).

Steps to reproduce:

  1. Have a C++ file with GBK encoding containing Chinese comments
  2. Use Edit tool to modify a small portion of code
  3. Check the file - existing Chinese comments are now corrupted/garbled

Expected behavior: Edit tool should preserve the original file encoding (GBK/GB2312) and not corrupt existing content outside the modified lines.

Actual behavior: The Edit tool appears to convert the file to a different encoding (UTF-8), causing all existing Chinese comments in the file to become unreadable.

Environment: Windows 10, working with legacy C++ projects that use GBK encoding


希望这个问题能得到修复,让Edit工具能正确处理不同编码的文件。 而且使用sed时,文件的换行符CRLF被修改为LF

What Should Happen?

修改代码时,要保持文件编码不变

Error Messages/Logs

Steps to Reproduce

使用claude修改代码时,如果文件是GBK编码,修改后会中文乱码,换行符也被改了。希望保持原文件编码不变

Claude Model

None

Is this a regression?

Yes, this worked in a previous version

Last Working Version

No response

Claude Code Version

2.1.107

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

Windows Terminal

Additional Information

No response

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] Edit tool corrupts GBK-encoded Chinese comments in source files