Windows: Bash tool garbles output from native Windows commands due to UTF-16LE encoding mismatch

Resolved 💬 3 comments Opened Mar 7, 2026 by yiminhale Closed Mar 10, 2026

Summary

On Windows, the Bash tool produces garbled/mojibake output when running native Windows commands (e.g., wsl.exe, chcp.com, powershell.exe) that output non-ASCII characters (e.g., Korean, Chinese, Japanese). This affects all Windows users with non-English locales.

Root Cause

The Bash tool always uses Git Bash (/usr/bin/bash) as its shell on Windows, which expects UTF-8 encoded input. However, many native Windows executables (notably wsl.exe) output text encoded in UTF-16LE, regardless of the system's active code page. This encoding mismatch causes:

  1. Null bytes between ASCII characters (UTF-16LE uses 2 bytes per ASCII char), resulting in spaced-out text like W S L v e r s i o n
  2. Non-ASCII characters (e.g., Korean, CJK) rendered as ??? or garbage, since the byte sequences are misinterpreted

Reproduction Steps

  1. Set up Claude Code on a Windows machine with a non-English locale (e.g., Korean, ko_KR)
  2. Run any native Windows command that outputs localized text:

``
wsl --version
wsl --list --online
chcp.com
``

  1. Observe garbled output in the tool results

What I Tried (User-side mitigations — none fully worked)

| Mitigation | Result |
|---|---|
| Setting Windows system locale to UTF-8 (Beta feature: "Use Unicode UTF-8 for worldwide language support") | Code page changed from 949 → 65001, but wsl.exe still outputs UTF-16LE. No improvement for these commands. |
| Stripping null bytes with sed 's/\x00//g' | English text becomes readable, but non-ASCII characters remain garbled |
| Running commands through powershell.exe -Command "..." | Same garbled output — the Bash tool still captures it as raw bytes |
| Configuring PowerShell profile ($OutputEncoding, [Console]::OutputEncoding) | No effect, since Claude Code does not use PowerShell as its shell |

Expected Behavior

Native Windows command output should be correctly decoded and displayed, including non-ASCII characters, regardless of the user's locale.

Suggested Solutions

  1. Auto-detect and convert UTF-16LE output in the Bash tool's output capture layer (e.g., check for BOM or null-byte patterns and convert to UTF-8)
  2. Support PowerShell as an alternative shell on Windows (PowerShell can handle encoding natively via [Console]::OutputEncoding)
  3. Add an encoding conversion layer specifically for Windows native command execution

Environment

  • OS: Windows 11 Education 10.0.29531
  • Claude Code shell: Git Bash (/usr/bin/bash)
  • System locale: Korean (ko_KR.UTF-8)
  • Active code page: 65001 (UTF-8, after manual change)
  • LANG: ko_KR.UTF-8
  • Platform: win32

Example Output

Raw output from wsl --version:

W S L   ���:   2 . 6 . 3 . 0
���  ���:   6 . 6 . 8 7 . 2 - 1

Expected output:

WSL 버전: 2.6.3.0
커널 버전: 6.6.87.2-1

---

This issue was authored by Claude (Opus 4.6) via Claude Code on behalf of the user, based on a live debugging session where we systematically identified and verified the root cause.

View original on GitHub ↗

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