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

Unicode Input Handling Fails for Vietnamese Characters

Open nhungbeo opened this issue 5 months ago • 15 comments

Bug Description Tôi bị lôỗi khi gõ tiếng viêệt!

Environment Info

  • Platform: win32
  • Terminal: windows-terminal
  • Version: 1.0.56
  • Feedback ID: 7b114bfe-3eb8-44a0-a767-4161b53b31a1

Errors

[{"error":"Error: ENOENT: no such file or directory, open 'C:\\proc\\version'\n    at Module.readFileSync (node:fs:441:20)\n    at Object.readFileSync (file:///C:/Users/Administrator/.npm-global/node_modules/@anthropic-ai/claude-code/cli.js:615:7077)\n    at file:///C:/Users/Administrator/.npm-global/node_modules/@anthropic-ai/claude-code/cli.js:615:8638\n    at Q (file:///C:/Users/Administrator/.npm-global/node_modules/@anthropic-ai/claude-code/cli.js:609:14408)\n    at kT4 (file:///C:/Users/Administrator/.npm-global/node_modules/@anthropic-ai/claude-code/cli.js:709:62815)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)","timestamp":"2025-07-19T01:46:53.728Z"},{"error":"RangeError [ERR_CHILD_PROCESS_STDIO_MAXBUFFER]: stdout maxBuffer length exceeded\n    at Socket.onChildStdout (node:child_process:482:14)\n    at Socket.emit (node:events:518:28)\n    at Socket.emit (node:domain:489:12)\n    at addChunk (node:internal/streams/readable:561:12)\n    at readableAddChunkPushByteMode (node:internal/streams/readable:512:3)\n    at Readable.push (node:internal/streams/readable:392:5)\n    at Pipe.onStreamRead (node:internal/stream_base_commons:189:23)","timestamp":"2025-07-19T01:46:55.107Z"}]

nhungbeo avatar Jul 19 '25 01:07 nhungbeo

Same issue

letrungtrieu avatar Jul 25 '25 15:07 letrungtrieu

same issue with Mac, pls fix

tuanquok avatar Jul 28 '25 14:07 tuanquok

I ran into the same problem. While waiting for the official fix, I created a patch script that you can use as a temporary workaround

Image

Source: https://gist.github.com/qtnx/2850b394923e94f7db4cca9446fed660

To apply it, run:

curl -fsSL https://gist.githubusercontent.com/qtnx/2850b394923e94f7db4cca9446fed660/raw/fix-vietnamese-claude-code.sh | bash

It works on macOS and Linux. Windows may require WSL.

Remember to read the script before running it. You might need to reapply the patch after future updates.

qtnx avatar Aug 18 '25 11:08 qtnx

I ran into the same problem. While waiting for the official fix, I created a patch script that you can use as a temporary workaround

Image Source: https://gist.github.com/qtnx/2850b394923e94f7db4cca9446fed660

To apply it, run:

curl -fsSL https://gist.githubusercontent.com/qtnx/2850b394923e94f7db4cca9446fed660/raw/fix-vietnamese-claude-code.sh | bash It works on macOS and Linux. Windows may require WSL.

Remember to read the script before running it. You might need to reapply the patch after future updates.

Still face issue, I have log 'Could not find g1 function pattern This version of Claude Code may have a different structure'

tuanquok avatar Aug 18 '25 14:08 tuanquok

I ran into the same problem. While waiting for the official fix, I created a patch script that you can use as a temporary workaround Image Source: https://gist.github.com/qtnx/2850b394923e94f7db4cca9446fed660 To apply it, run: curl -fsSL https://gist.githubusercontent.com/qtnx/2850b394923e94f7db4cca9446fed660/raw/fix-vietnamese-claude-code.sh | bash It works on macOS and Linux. Windows may require WSL. Remember to read the script before running it. You might need to reapply the patch after future updates.

Still face issue, I have log 'Could not find g1 function pattern This version of Claude Code may have a different structure'

It might not work with the latest version 1.0.84, so I’ll update it.

As a workaround on macOS, you can try:

  1. Using the default Telex keyboard from macOS (works fine) - setup in the Text Input setting.
  2. iTerm2 - sometimes it works.
  3. The terminal in Zed IDE — works without any issues.

qtnx avatar Aug 19 '25 03:08 qtnx

I've just updated the script it should work now.

qtnx avatar Aug 19 '25 06:08 qtnx

I've just updated the script it should work now.

You've save my life. Ty ( Cảm ơn bác :)))))

tuanquok avatar Aug 19 '25 09:08 tuanquok

Same issue. Please fix.

JOY avatar Sep 03 '25 14:09 JOY

Same issue, but with Portuguese (Brazil) Characters...

lucas3g avatar Oct 14 '25 16:10 lucas3g

UP

lucas3g avatar Oct 21 '25 16:10 lucas3g

up

lucas3g avatar Oct 23 '25 18:10 lucas3g

This issue seems to cover a multitude of sins but all the related (and more directly relevant) issues have been closed as duplicates of this, so I'll add details here.

Platform: claude code, windows 11 pro, launched from powershell terminal (git bash not supported, I didn't even consider cmd).

Claude generates code with a LOT of unicode symbols, ticks, crosses, arrows, exclamation icons, but if it tries to run any of this code it will crash the run (not the console) immediately when the symbol is output. Claude will usually recognise the mistake and rewrite the code. This is a phenomenal waste of tokens and time. The code is fine, it works if I launch it manually and the unicode symbols are not a problem in the powershell terminal. It is ONLY a problem INSIDE Claude Code.

Simple repro: python print("✓ Test completed successfully") Save as bug-test.py Ask Claude Code to run that script.

Result:

● Bash(cd "F:\ai\The Thinker" && python bug-test.py)
  ⎿  Error: Traceback (most recent call last):
       File "F:\ai\The Thinker\bug-test.py", line 1, in <module>
         print("\u2713 Test completed successfully")
       File "F:\miniconda3\Lib\encodings\cp1252.py", line 19, in encode
         return codecs.charmap_encode(input,self.errors,encoding_table)[0]
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     UnicodeEncodeError: 'charmap' codec can't encode character '\u2713' in position 0: character maps to <undefined>

Expected result: Script should run without error.

Claude Code reports:

  The issue is Windows Command Prompt defaulting to cp1252 encoding instead of UTF-8, preventing unicode characters
  like ✓ (\u2713) from being displayed.

I launch Claude Code from PowerShell terminal, so either the Command Prompt diagnosis is incorrect, or Claude Code ignores its environment and runs code in an unsuitable alternative.

pjbaron avatar Oct 26 '25 13:10 pjbaron

I have no idea how much of this is hallucination, but Claude Code continued to report:

> I launched code claude inside window PowerShell terminal which doesn't usually have any problems with encoding.
When you run these scripts are you opening a command prompt shell instead of using the host environment?

● You've identified the issue! Looking at the error traceback showing cp1252.py, you're absolutely right - when I
  use the Bash tool, it appears to be spawning a Windows Command Prompt (cmd.exe) process with cp1252 encoding,
  rather than using the PowerShell environment you launched Claude Code from.

  PowerShell uses UTF-8 by default (or at least handles Unicode much better), but cmd.exe defaults to cp1252 which
  causes the unicode errors.

  I don't have direct control over which shell the Bash tool uses, but this is clearly a bug in how Claude Code
  handles the Bash tool on Windows - it should either:

  1. Inherit the shell environment from the host (your PowerShell session)
  2. Set UTF-8 encoding explicitly when spawning child processes: chcp 65001 in cmd.exe
  3. Provide a way to configure which shell to use

  For your bug report, the key details are:
  - Host environment: Windows PowerShell (UTF-8 capable)
  - Expected behavior: Bash tool should use PowerShell or set UTF-8 encoding
  - Actual behavior: Bash tool spawns cmd.exe with cp1252 encoding
  - Evidence: Error shows cp1252.py codec in traceback
  - Impact: Python scripts with unicode characters fail even though host terminal supports them

pjbaron avatar Oct 26 '25 13:10 pjbaron

Same issue. Please fix.

namkiit avatar Nov 25 '25 07:11 namkiit

https://github.com/trancong12102/claude-code-vime You can try my script, which has been updated for the latest Claude code version.

trancong12102 avatar Dec 02 '25 04:12 trancong12102

I have developed a Vietnamese input engine on macOS to fix this issue in Claude Code and other apps. You can use it here:

https://github.com/khaphanspace/gonhanh.org

khaphanspace avatar Dec 09 '25 02:12 khaphanspace

up

thanhdongnguyen avatar Dec 17 '25 03:12 thanhdongnguyen

@claude please fix it

thanhdongnguyen avatar Dec 17 '25 03:12 thanhdongnguyen