Skip to content

PowerShell shell output is mojibake on Windows unless UTF-8 OutputEncoding is set #31345

Closed

Description

@qinant

Description

Image ### Describe the bug

On Windows, shell tool output from PowerShell can render Chinese text as mojibake when the command does not explicitly set UTF-8 output encoding.

Possible cause.Opencode appears to decode shell stdout as UTF-8, but PowerShell on Windows may emit output using the active console code page unless [Console]::OutputEncoding is set to UTF-8. This causes non-ASCII output to be decoded incorrectly.

A possible fix is to wrap PowerShell shell commands with:

[Console]::OutputEncoding = [System.Text.UTF8Encoding]::new($false)
$OutputEncoding = [Console]::OutputEncoding

Plugins

None

OpenCode version

v1.16.2

Steps to reproduce

just input opencode prompts below
use pwsh exec command: Write-Output "测试中文输出"

Image

You can observe Chinese text as mojibake

Screenshot and/or share link

No response

Operating System

Windows 11

Terminal

PowerShell / pwsh

Activity

  1. github-actions commented on Jun 8, 2026

    @github-actions
    Contributor

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

    Please review these issues to see if your report is already covered. If it is, consider adding any new information there instead.

  2. qinant commented on Jun 8, 2026

    @qinant
    Author

    Its same as #23636 #31187 #30205

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