Panic: UTF-8 byte boundary error when rendering Chinese characters in Markdown tables
Description
Claude Code crashes with a Rust panic when rendering Markdown tables containing Chinese (CJK) characters. The error indicates an invalid UTF-8 byte boundary access.
Error Message
thread '<unnamed>' (138162) panicked at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/str/mod.rs:833:21:
byte index 2 is not a char boundary; it is inside '源' (bytes 0..3) of `源 | System Prompt |`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 5, aborting
Aborted (core dumped)
Steps to Reproduce
- Ask Claude to output a Markdown table containing Chinese characters
- The table in question had content like:
| 模式 | 有引用來源 | 全新問題無引用 | 追問無引用 | System Prompt |
|------|------------|---------------|-----------|:-------------:|
| `force` | 顯示回答 | **阻擋** | 回答 + 警告 | ✓ |
- Claude Code crashes when rendering/processing this output
Root Cause Analysis
The Chinese character 源 (from 引用來源) occupies 3 bytes in UTF-8 (bytes 0..3). The code attempts to slice at byte index 2, which is in the middle of this multi-byte character, causing the panic.
This suggests the rendering code is treating byte offsets as character offsets when processing table column widths or text truncation.
Environment
- Claude Code version: 2.0.76
- OS: Ubuntu 24.04 (Linux 6.8.0-90-generic)
- Architecture: x86_64
- Locale: UTF-8
Expected Behavior
Claude Code should correctly handle multi-byte UTF-8 characters when rendering Markdown tables, using character boundaries instead of byte offsets for string operations.
Workaround
None currently available. The crash occurs during output rendering.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗