Skip to content

Occasional garbled Chinese characters in streaming output #59804

Description

@stormzhang

Description

When Claude Code streams responses containing Chinese text, occasionally a few characters appear garbled/mojibake (e.g., "看下���果" instead of "看下效果") while all surrounding characters render correctly.

Environment

  • Claude Code CLI (macOS)
  • Terminal: default zsh
  • Model: claude-opus-4-6

Root cause hypothesis

UTF-8 Chinese characters are 3 bytes each. When the streaming response chunks happen to split at a byte boundary within a multi-byte character, the terminal renders the incomplete bytes as replacement characters (�).

Reproduction

  • Not reliably reproducible — it's a race condition dependent on where chunk boundaries fall
  • Happens occasionally in longer responses mixing Chinese and ASCII text
  • Only a few characters are affected per occurrence, not entire lines

Expected behavior

All multi-byte characters should be buffered correctly before rendering, regardless of chunk boundaries.

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions