Rust panic: UTF-8 string slicing error with Korean characters
Resolved 💬 3 comments Opened Dec 31, 2025 by edari-bridge Closed Jan 4, 2026
Description
Claude Code CLI crashes with a Rust panic when processing Korean text. The error occurs during UTF-8 string handling where the code attempts to slice at a byte index that falls inside a multi-byte character.
Error Message
thread '<unnamed>' (4601747) 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 `료, 나만의 API 키로 이미지 생성.`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 5, aborting
zsh: abort claude
Analysis
- The Korean character '료' is encoded as 3 bytes in UTF-8 (bytes 0-2)
- The code attempts to slice the string at byte index 2
- Byte index 2 is inside the '료' character, not at a valid character boundary
- This causes a Rust panic
Environment
- OS: macOS (Darwin 24.6.0)
- Shell: zsh
Expected Behavior
Claude Code should properly handle UTF-8 multi-byte characters (Korean, Japanese, Chinese, emoji, etc.) without crashing.
Suggested Fix
Use character-aware string operations instead of byte-based slicing. In Rust, this typically means using .chars() iterator or char_indices() instead of direct byte indexing.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗