Rust panic: UTF-8 string boundary error when editing CJK content
Resolved 💬 4 comments Opened Jan 11, 2026 by paul-lai-mobile Closed Feb 26, 2026
Description
Claude Code crashes with a Rust panic when editing files containing CJK (Chinese/Japanese/Korean) characters. The crash occurs during Edit operations when the tool attempts to display or truncate text containing multi-byte Unicode characters.
Error Messages
thread '<unnamed>' panicked at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/str/mod.rs:833:21:
byte index 9 is not a char boundary; it is inside '詞' (bytes 7..10) of `個word詞");`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 5, aborting
thread '<unnamed>' 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 `二");`
Steps to Reproduce
- Edit a file containing CJK characters (e.g., Objective-C test file with Chinese strings)
- Make multiple small Edit operations on lines containing CJK content
- The crash occurs when the edit preview/display truncates text at a byte boundary that falls inside a multi-byte character
Root Cause
The Rust code is using byte indices to slice UTF-8 strings, but CJK characters are 3 bytes each. When truncating for display, the code lands in the middle of a character, causing a panic.
Environment
- Claude Code v2.1.4
- macOS (Darwin 25.2.0)
- Editing Objective-C test files with Chinese character test strings
Suggested Fix
Use character-aware string slicing:
str.chars().take(n)instead of byte slicing- Or use
str.char_indices()to find safe truncation points - Or use
floor_char_boundary()(Rust 1.73+) before slicing
Workaround
Using the Write tool for larger file sections instead of multiple small Edit operations reduces the frequency of crashes.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗