Conversation
Contributor
|
The following comment was made by an LLM, it may be inaccurate: Potential Duplicate PRs Found:
These PRs likely cover the same root cause (encoding mismatch when PowerShell outputs on Windows). You should verify if PRs #31658 and #36608 already resolve this issue or if they only partially address it. |
Windows PowerShell 5.1 encodes its stdout with the legacy OEM code page (e.g. CP936 on zh-CN systems) when output is redirected, while opencode decodes process output as UTF-8, producing mojibake for any non-ASCII shell output. Prepend a [Console]::OutputEncoding/$OutputEncoding UTF-8 preamble to PowerShell commands spawned by the shell tool and bang commands on Windows. Permission scanning and command titles still use the original command text since the preamble is injected at spawn time. Corresponds to upstream discussion in anomalyco#23636.
ysmla
force-pushed
the
fix/windows-powershell-utf8
branch
from
September 15, 2026 05:31
042190d to
8d5aa07
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #30205
Related: #30055, #23636
Type of change
What does this PR do?
解决Windows下,opencode中模型使用powershell输出中文时会出现乱码的问腿
How did you verify your code works?
在中文 Windows 11 + PowerShell 5.1 环境下,用与工具相同的方式启动 PowerShell(管道输出 stdout),会得到 GBK 编码字节(b2e2 cad4 ...),证实了乱码的原因是编码不匹配,修复后,用重新构建的二进制做端到端测试,让模型执行 echo 测试中文:你好世界——打补丁前输出乱码,打补丁后能正确显示中文。


修复前后对比如下:
Checklist