anomalyco / anomalyco/opencode
[Windows] UTF-8/GBK mojibake in model thinking chain and assistant output
@Hona is already working on this.
Since Aug 8, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Summary
On Chinese Windows (zh-CN locale, console code page 936/GBK), CJK text in the model's thinking chain (reasoning block) and in regular assistant output frequently renders garbled — a UTF-8 ↔ GBK mismatch that is visible live in the UI, not only in exports.
Environment
- OS: Windows 10/11, Chinese (zh-CN) system locale, default console code page
936(GBK/CP936) - App: OpenCode Desktop
1.18.15(also reproduced in the terminal/TUI build) - Shell: PowerShell 5.1 (default ANSI/GBK on this machine)
- Model: any (reproduced with DeepSeek via proxy)
Observed
- The
thinking/reasoning block frequently shows garbled Chinese characters. - Assistant messages containing CJK are garbled the same way.
- Typical mojibake seen:
- UTF-8 bytes decoded as GBK → classic
锟斤拷-style garbage - Replacement characters
� - Text that is ASCII-correct but CJK-corrupt within the same message, implying an inconsistent decode path
- UTF-8 bytes decoded as GBK → classic
- Force-switching the console to UTF-8 (
chcp 65001) or setting[Console]::OutputEncoding = UTF8avoids the issue, which points at the console code page (CP936) being picked up somewhere in the render/stream pipeline.
Expected
All text — thinking chain and output — should be rendered consistently as UTF-8 regardless of the Windows console code page.
Reproduction steps
- On a zh-CN Windows machine (console code page
936), launch OpenCode Desktop or the TUI. - Ask a question that produces a long Chinese response with a visible reasoning/thinking block.
- Observe mojibake in the thinking block and in the assistant reply whenever CJK is present.
Root-cause hypothesis
Something in the TUI/desktop stream pipeline decodes the model's UTF-8 bytes using the console's GBK code page (or transcodes UTF-16 → CP936 before writing, like the known process.stdout behavior), producing the mismatch. This mirrors the export bug in #36050 but affects live rendering.
Related issues
- #36050 —
opencode exportgarbled CJK on Windows due toprocess.stdouttranscoding to console code page (same class of bug, export path only) - #36985, #23636 — PowerShell output encoding / console UTF-8 workarounds
- #31470 — Chinese text garbled when pasting in TUI input
- #31187 (closed) — garbled CJK due to Windows default ACP (GBK/CP936)
- #30055 (closed) — CLI shell uses GBK by default, Chinese garbled
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.