Conversation
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: Potential Duplicate PRs FoundThis PR appears to be directly related to previous Windows PowerShell UTF-8 encoding fixes:
Why they're related: All three PRs address the same core issue—fixing UTF-8 encoding problems for PowerShell output on Windows. PR #49012 mentions it's related to issues #30205 and #30055, and appears to implement a similar fix by injecting You should verify whether these previous PRs already resolved the issue or if this is addressing a gap they missed. |
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.
8aef152 to
042190d
Compare
|
This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window. Feel free to open a new pull request that follows our guidelines. |
Issue for this PR
Closes #
Type of change
What does this PR do?
修复opencode模型使用shell时的中文乱码问题
Closes #30205、#30055
If you paste a large clearly AI generated description here your PR may be IGNORED or CLOSED!
How did you verify your code works?
Opencode web中,模型使用shell输出中文的时候产生乱码如图:


发现PowerShell 5.1 管道输出用系统 OEM 代码页(CP936)编码、opencode 按 UTF-8 解码导致乱码;修复是在 Windows 上给 PowerShell 命令注入 [Console]::OutputEncoding UTF-8 前导语句,覆盖 shell 工具和 ! 命令两条路径,权限检查和界面显示不受影响,修复后如图:
Screenshots / recordings
No
If this is a UI change, please include a screenshot or recording.
Checklist
If you do not follow this template your PR will be automatically rejected.