claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] MultiEdit UTF-8 Encoding Bug Report

Open dascwf opened this issue 5 months ago • 1 comments

Environment

  • Platform (select one):
    • [ ] Anthropic API
    • [ ] AWS Bedrock
    • [ ] Google Vertex AI
    • [x] Other: Claude Code CLI with MultiEdit tool
  • Claude CLI version: 1.0.24 (Claude Code)
  • Operating System: Linux (root@build) Alpine Linux ^3.22.0
  • Terminal: Fish Shell 4.0.2+

Bug Description

The MultiEdit tool incorrectly handles UTF-8 encoded content when writing files, resulting in corrupted characters (mojibake). Chinese characters and special UTF-8 symbols are replaced with replacement characters (�) in the written files, while the same content displays correctly in the Claude interface.

Steps to Reproduce

  1. Use Claude Code to create a new markdown file with Chinese content:
    MultiEdit prompt/skeleton 3.1.3.md
    
  2. Include Chinese characters in the content, such as:
    • "骨架屏" (skeleton screen)
    • "中文文档" (Chinese documentation)
    • Special characters like "—" (em dash) or "•" (bullet)
  3. Save the file using MultiEdit
  4. Read the file back using:
    Read prompt/skeleton 3.1.3.md
    

Expected Behavior

  • File should be saved with proper UTF-8 encoding
  • Chinese characters and special symbols should be preserved
  • Reading the file should display the same content that was written

Actual Behavior

  • Chinese characters are replaced with � (replacement character)
  • Special UTF-8 characters are corrupted
  • File content shows mojibake when read back
  • Example: "骨架屏" becomes "��架��"

Additional Context

Test Case Evidence:

  • Claude interface displays: "骨架屏(Skeleton Screen)"
  • File contains: "��架��(Skeleton Screen)"

System Encoding:

$ echo $LANG
en_US.UTF-8

File Encoding Check:

$ file -bi "prompt/skeleton 3.1.3.md"
text/plain; charset=utf-8

Workaround: Currently avoiding Chinese characters and using only ASCII in documentation files.

Impact: This bug prevents creating multilingual documentation or using special UTF-8 characters through Claude Code's MultiEdit tool, limiting its usefulness for international users and technical documentation that requires special symbols.

Suggested Fix: Ensure MultiEdit tool explicitly uses UTF-8 encoding when writing files, possibly by:

  • Setting encoding explicitly in file write operations
  • Using Buffer.from(content, 'utf8') when handling string content
  • Ensuring all string transformations preserve UTF-8 encoding

dascwf avatar Jun 16 '25 15:06 dascwf

I encountered the same problem, when using Rider, the claude code was still correct when using IDE's difference comparison function, but when I clicked accept, the encoding was incorrect! This issue greatly affects usage and is equivalent to wasting a conversation! Please fix it as soon as possible!!!

eefan000 avatar Jun 23 '25 08:06 eefan000

MacOS, Vscode and

❯locale 
LANG="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_ALL="en_US.UTF-8"

Whenever claudecode writes markdown content, It always writes like this: "�� Workers-Hono (Cloudflare), � Pending:, � Pending:"

Image

I set up corretly locales, Lang stuff. Other AI CLI tools have no issue but only Claudecode.

aifirstd3v avatar Jul 17 '25 22:07 aifirstd3v

MacOS cursor:

Image

tjx666 avatar Jul 24 '25 12:07 tjx666

I got same issue

CorrectRoadH avatar Aug 16 '25 05:08 CorrectRoadH

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/1716
  2. https://github.com/anthropics/claude-code/issues/5047
  3. https://github.com/anthropics/claude-code/issues/5111

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

github-actions[bot] avatar Aug 16 '25 06:08 github-actions[bot]

This issue has been automatically closed as a duplicate of #1716.

If this is incorrect, please re-open this issue or create a new one.

🤖 Generated with Claude Code

github-actions[bot] avatar Aug 21 '25 09:08 github-actions[bot]

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.

github-actions[bot] avatar Aug 29 '25 14:08 github-actions[bot]