Non-ASCII characters in command output display as replacement characters on Windows
Environment
- OS: Windows 11
- Claude Code VSCode Extension: 2.1.72
- Shell: Git Bash
- System locale: French (applies to any non-English locale)
- Console code page: 437 (US OEM)
Description
When a Bash tool command outputs non-ASCII characters (accented letters like é, è, ü, etc.), they appear as � (U+FFFD replacement characters) in the Claude Code chat UI.
This affects any command that produces non-ASCII output, including:
- PowerShell error messages in non-English Windows locales
curlresponses with UTF-8 content- Any program outputting accented/CJK/Cyrillic characters
Steps to Reproduce
- Windows system with non-English locale (e.g., French)
- Run any command that produces accented output, for example:
````
powershell.exe -Command 'Write-Error "Le délai d''exécution a expiré"'
- The output in Claude Code chat shows:
```
Le d�lai d'ex�cution a expir�
`
Instead of:
``
Le délai d'exécution a expiré
Root Cause
On Windows, the default console code page is 437 (US OEM) or similar non-UTF-8 encoding. When programs like PowerShell write to stdout/stderr, they use the console's code page encoding. The CLI binary reads this output as UTF-8, causing multi-byte characters in CP437/CP1252 to be interpreted as invalid UTF-8 sequences, which get replaced with U+FFFD (�).
The data flow:
- CLI spawns
bash.exe(git-bash) → runs user command (e.g.,powershell.exe) - PowerShell outputs French error text encoded in CP437:
é= byte0x82 - CLI reads stdout as UTF-8: byte
0x82is invalid UTF-8 → replaced with�(U+FFFD)
Suggested Fix
Set the console code page to 65001 (UTF-8) before running commands on Windows. This can be done by:
- Running
chcp 65001in the bash session (verified to fix the issue):
``bash``
chcp.com 65001 > /dev/null 2>&1
- Setting
BASH_ENVenvironment variable to a script that runschcp 65001— this ensures all non-interactive bash sessions spawned by the CLI use UTF-8. - Or equivalently, adding
chcp.com 65001 > /dev/null 2>&1to the bash command prefix when spawning commands on Windows.
Additionally, setting PYTHONUTF8=1 and PYTHONIOENCODING=utf-8 in the CLI process environment helps Python scripts output UTF-8 on Windows.
Workaround
Users can add chcp.com 65001 > /dev/null 2>&1 to their ~/.bashrc to force UTF-8 globally in git-bash sessions.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗