Skip to content

Shell output panel decodes UTF-8 as ANSI/GBK on Windows, causing Chinese garbled text #12315

@YuSeventeen

Description

@YuSeventeen

Before submitting your bug report

Relevant environment info

- **OS**: Windows 11 (Chinese Simplified locale)
    - **DeepSeek TUI**: bundled with Kiro IDE (`kiro.kiro-agent`)
    - **Terminal**: PowerShell 5.1, code page 65001 (UTF-8)
    - **System setting**: "Beta: Use Unicode UTF-8 for worldwide language support" —
    enabled

Description

Current behavior

The **shell output panel** (`exec_shell`) displays non-ASCII characters as garbled
text (mojibake). The **chat panel** renders the same Chinese characters correctly.

## Steps to reproduce

1. On Windows 11 with a Chinese system locale, open Kiro IDE
2. Ensure `chcp 65001` is active
3. Run `whoami` via `exec_shell` (if machine name contains CJK characters)
4. Observe garbled output in the shell panel
5. The same text displayed in the chat panel renders correctly

## Root cause

`whoami` outputs valid UTF-8 bytes:

raw bytes: e7bebd5c31333234370d0a

| Decoding | Result |
|----------|--------|
| UTF-8 (correct) | `羽\13247` |
| GBK / CP936 (what the panel shows) | `缇絓13247` |

The shell output panel's rendering pipeline decodes captured stdout using the
Windows ANSI code page (CP936/GBK), while the chat panel correctly uses UTF-8.

## Expected behavior

The shell output panel should decode subprocess stdout as UTF-8, matching the chat
panel and the system's configured encoding.

## Workaround

None. `sys.stdout.reconfigure(encoding='utf-8')` in Python does not help — the
data is already valid UTF-8 when it reaches the TUI. The corruption happens in the
TUI's terminal rendering layer.

## Relevant config

settings.toml
────────────────────────────────────────
locale = "zh-Hans"

config.toml
────────────────────────────────────────
defaulttextmodel = "deepseek-v4-pro"
reasoning_effort = "max"
No encoding-related setting available
────────────────────────────────────────

────────────────────────────────────────────────────────────

To reproduce

No response

Log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind:bugIndicates an unexpected problem or unintended behavioros:windowsHappening specifically on Windows

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions