Panic: UTF-8 string slicing error with Korean text
Resolved 💬 3 comments Opened Dec 30, 2025 by jemulpoclub Closed Jan 2, 2026
Bug Description
Claude Code crashes with a Rust panic when processing Korean text. The program attempts to slice a string at a byte index that falls in the middle of a multi-byte UTF-8 character.
Error Message
thread '<unnamed>' (2633564) panicked at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/str/mod.rs:833:21:
byte index 33 is not a char boundary; it is inside '요' (bytes 31..34) of `뉴스레터를 공유해주세요</p>`
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)
Environment
- Claude Code Version: 2.0.76
- OS: Linux (RHEL/CentOS 9, kernel 5.14.0-605.el9.x86_64)
- Platform: x86_64
Root Cause Analysis
The error occurs because the code is slicing a UTF-8 string at byte offset 33, but Korean characters (like '요') occupy 3 bytes each in UTF-8 encoding. Byte index 33 falls inside the character '요' (bytes 31-34), causing a panic.
The problematic string appears to be: 뉴스레터를 공유해주세요</p>
Suggested Fix
Use character-aware string operations instead of byte-based slicing:
// Instead of: &text[0..33]
// Use: text.chars().take(n).collect::<String>()
// Or find valid char boundary before slicing
Additional Context
This bug affects users working with Korean (and likely other CJK languages or any non-ASCII text) in their codebases.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗