Non-ASCII characters in command output display as replacement characters on Windows

Resolved 💬 3 comments Opened Mar 10, 2026 by slonm-cf Closed Mar 14, 2026

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
  • curl responses with UTF-8 content
  • Any program outputting accented/CJK/Cyrillic characters

Steps to Reproduce

  1. Windows system with non-English locale (e.g., French)
  2. Run any command that produces accented output, for example:

``
powershell.exe -Command 'Write-Error "Le délai d''exécution a expiré"'
``

  1. 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:

  1. CLI spawns bash.exe (git-bash) → runs user command (e.g., powershell.exe)
  2. PowerShell outputs French error text encoded in CP437: é = byte 0x82
  3. CLI reads stdout as UTF-8: byte 0x82 is 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:

  1. Running chcp 65001 in the bash session (verified to fix the issue):

``bash
chcp.com 65001 > /dev/null 2>&1
``

  1. Setting BASH_ENV environment variable to a script that runs chcp 65001 — this ensures all non-interactive bash sessions spawned by the CLI use UTF-8.
  2. Or equivalently, adding chcp.com 65001 > /dev/null 2>&1 to 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.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗