Skip to content

bash.ts: hardcoded UTF-8 decoding produces garbled output on non-UTF-8 systems #30869

Closed

Description

Description

File: packages/core/src/tool/bash.ts:173

const compact = compactOutput(result.stdout.toString("utf8"), result.stderr.toString("utf8"))

On Windows with CJK locales (e.g., Chinese GBK encoding chcp 936), compiler error messages are UTF-8 decoded from GBK bytes, producing mojibake (garbled characters). AI sees unreadable text → cannot diagnose build failures.

Fix: Use platform-appropriate encoding:

const encoding = process.platform === "win32" ? "utf16le" : "utf8"

OpenCode version

v1.16.0 (commit 3cf1cef)

Activity

  1. github-actions commented on Jun 5, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Please review those issues and, if your issue is distinct, clarify how it differs.

  2. skywalker-35 commented on Jun 16, 2026

    @skywalker-35

    Same issue here on Chinese Windows (code page 936/GBK). The bash tool hardcodes result.stdout.toString("utf8") at line 173 in bash.ts, but Windows system commands output in the system's active code page (GBK on zh-CN). The simple fix would be to detect the system encoding on Windows via chcp.com and use the appropriate decoder.

    Related issues: #31187, #26882, #31830, #31765

    Many Chinese/Japanese/Korean Windows users are affected by this. Please consider fixing it in an upcoming release. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions