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
fix(shell): use PowerShell EncodedCommand for reliable UTF-8 output on Windows
On Windows, PowerShell commands were passed via -Command flag, causing
encoding corruption when the active console code page is not UTF-8
(e.g. GBK/CP936 on zh-CN systems, Shift-JIS/CP932 on ja-JP systems).
The UTF-8 preamble added by previous attempts runs too late because
-Command parses the string in the current code page before execution.
This change switches to -EncodedCommand with Base64(UTF-16LE) encoding,
which guarantees the command string survives transport intact regardless
of the console code page. The original command is base64-encoded (UTF-8)
and embedded in the payload, then decoded at runtime via
[scriptblock]::Create() after the UTF-8 preamble has already taken
effect. This avoids prepending statements before the user command,
which would break param() blocks and #requires directives.
The encoding logic is extracted into a shared module
(core/shell/powershell.ts) used by all three PowerShell execution paths:
- packages/core/src/tool/bash.ts (core bash tool)
- packages/opencode/src/tool/shell.ts (opencode shell tool)
- packages/opencode/src/shell/shell.ts (TUI direct shell mode)
Closes#23636Closes#31187Closes#30205Closes#31830Closes#26882
Co-Authored-By: Claude <noreply@anthropic.com>
0 commit comments