You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Windows CJK characters garbled in bash tool output #24080
On Windows with CJK locales (zh-CN, ja-JP, ko-KR), the bash tool spawns child processes that inherit the system default code page (e.g. 936 GBK) instead of UTF-8. The parent process may have chcp 65001 set, but it is NOT inherited by spawned child processes. This causes non-ASCII output to be encoded in the system ANSI encoding while OpenCode reads it as UTF-8, producing garbled text.
Changes
One file: packages/opencode/src/tool/bash.ts, in the cmd() function.
PowerShell branch: Adds chcp 65001, [Console]::OutputEncoding, and $OutputEncoding — all three are needed because:
Setting
Scope
chcp 65001
Console code page
[Console]::OutputEncoding
.NET output encoding
$OutputEncoding
PowerShell pipeline encoding
cmd.exe branch: chcp 65001 alone is sufficient (no .NET encoding layer).
Reproducing
On a Chinese/Japanese/Korean Windows system:
# Without fix: garbled outputWrite-Output"你好世界"# outputs garbled text like "ä½ å¥½ä¸ç\U+fffd\U+fffd"# With fix: correct outputWrite-Output"你好世界"# outputs "你好世界"
Testing
A single file change in cmd() function
Win32-only code path, does not affect macOS/Linux
Only modifies the spawned command prefix, does not change tool behavior
This issue might be a duplicate of existing issues. Please check:
fix: PowerShell output encoding for non-ASCII characters on Windows #23636: Nearly identical bug — PowerShell output encoding for non-ASCII/CJK characters on Windows, same root cause (system code page not inherited by spawned processes), same proposed fix (prepend UTF-8 encoding settings to the PowerShell command)
Duplicate of #23636. The fix is already implemented and tested on my fork — I added a comment on that issue with the complete implementation details including the cmd.exe branch fix that the original proposal missed.
Activity
github-actions commentedon Apr 24, 2026
This issue might be a duplicate of existing issues. Please check:
[Console]::OutputEncoding,chcp 65001)Please review these issues before proceeding, as your report covers the same problem and proposed fix as #23636 in particular.
fkyah3 commentedon Apr 24, 2026
Duplicate of #23636. The fix is already implemented and tested on my fork — I added a comment on that issue with the complete implementation details including the cmd.exe branch fix that the original proposal missed.