Panic on UTF-8 boundary when processing Chinese characters
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Description
Claude Code crashes with a Rust panic when processing files containing Chinese characters.
Error Message
thread '<unnamed>' (864528) 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 辑 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
Environment
- Claude Code version: 2.0.71
- OS: macOS (Darwin 24.2.0)
- Context: Opened a file (
ai_mapping/log.md) that likely contains Chinese text
Root Cause
The code appears to be slicing a UTF-8 string at byte index 2, which falls in the middle of a 3-byte Chinese character '辑' (U+8F91). This is invalid in UTF-8 and causes a panic.
What Should Happen?
Claude Code should handle UTF-8 strings correctly without crashing. When truncating strings for display (e.g., status line, file paths), it should use character-aware operations that respect UTF-8 boundaries instead of byte-based slicing.
Error Messages/Logs
thread '<unnamed>' (864528) 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 `辑`
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
Steps to Reproduce
- Have a markdown file containing Chinese characters (e.g.,
ai_mapping/log.md) - Open the file in VSCode IDE
- Run Claude Code in the same session
- The crash occurs, possibly when rendering status line or processing file content
- The character '辑' (part of word like "编辑") triggers the boundary error
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.0.71
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
iTerm2
Additional Information
The crash appears to be in string truncation logic, likely in the status line or UI rendering code. The Chinese character '辑' (U+8F91) is 3 bytes in UTF-8 (E8 BE 91), and the code incorrectly tries to slice at byte index 2.
Suggested fix: Use str.char_indices() or str.chars() for safe truncation in Rust.
24 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
Hello, I have the same issue inside my cloud with Chinese characters. I've taken a screenshot if you want to use it.
### Description
When using the Edit tool to modify files containing Chinese (CJK) characters, the tool incorrectly reports that valid UTF-8 characters are invalid, causing the edit operation to fail.
### Error Message
Error: old_string (length XXX) contains X characters that are not valid UTF-8
### Environment
### Steps to Reproduce
old_stringcontaining Chinese text### Expected Behavior
The Edit tool should correctly handle valid UTF-8 multi-byte characters, including Chinese, Japanese, Korean, and other non-ASCII characters.
### Actual Behavior
The Edit tool's validation incorrectly flags valid Chinese characters as invalid UTF-8, preventing any edits to files containing CJK content.
### Technical Context
Chinese characters are valid multi-byte UTF-8 sequences (typically 3 bytes per character). The validation logic appears to be incorrectly interpreting these multi-byte sequences.
### Workaround
Using the
Writetool to rewrite the entire file instead of theEdittool for targeted changes. This is not ideal for large files or small edits.### Impact
### Screenshot
<img width="758" height="827" alt="Image" src="https://github.com/user-attachments/assets/49c42e6a-450e-4517-972f-24b0e44d6fb3" />
This bug makes Claude Code completely unusable for any project involving CJK (Chinese, Japanese, Korean) characters. The CLI crashes immediately when processing multilingual text.
My use cases affected:
As a developer working on internationalized applications, I frequently need to handle multiple Asian languages simultaneously. This panic issue forces me to either:
This is a critical bug that affects all developers working with Asian languages. Please prioritize this fix.
Environment:
same to me
Same here: thread '<unnamed>' (2001) panicked at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/str/mod.rs:833:21:
byte index 14 is not a char boundary; it is inside '息' (bytes 12..15) of
粘稠的窒息。浓云压顶的夜空没有星月,唯有远方闪电在云层深处游走,瞬间照亮荒原上枯树狰狞的枝桠,又迅速被黑暗吞没。note: run with
RUST_BACKTRACE=1environment variable to display a backtracefatal runtime error: failed to initiate panic, error 5, aborting
Aborted (core dumped)
did anyone try to downgrade claude code?
Yes, I am using 2.0.69, this issue was introduced in 2.0.70, there have been a lot of feedback on the issues, but there has never been a fixed (2.0.76).
Same here:
thread '<unnamed>' (6383911) panicked at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/str/mod.rs:833:21:
byte index 40 is not a char boundary; it is inside '度' (bytes 38..41) of
选中第一个 detent 作为初始高度。note: run with
RUST_BACKTRACE=1environment variable to display a backtracefatal runtime error: failed to initiate panic, error 5, aborting
[1] 54303 abort claude --dangerously-skip-permissions
Same here:
Claude Code v2.1.1
Same issue here with Japanese text.
Environment:
Error message:
This happens frequently when using the Write tool on Markdown files containing Japanese text. The crash is intermittent but very disruptive for users working in Japanese.
Same problem with 2.1.2 When will this be fixed?
Could you raise the priority of this issue? It really affects usability.
A quick keyword search reveals more than 100 frequent, similar issues. Are the Claude Code team really unaware of this? fix PR hasn't been reviewed in two weeks
@bcherny
thread '<unnamed>' (1194280) panicked at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb\library\core\src\str\mod.rs:833:21:
byte index 5 is not a char boundary; it is inside '요' (bytes 3..6) of
세요."note: run with
RUST_BACKTRACE=1environment variable to display a backtraceclaude code windows native, V2.1.2.
this bug has showed up again since i experienced same bug like, a month ago.
Anthropic guys think we are not so valuable clients?
This bug has been open for weeks and makes Claude Code unreliable
for all CJK users. Any timeline on a fix? Claude Code v2.1.3
Hi team,
I'm also affected by this bug. I'm a Max subscriber using Claude Code daily, and this issue makes the
--resumefeature completely unusable for Chinese-speaking users.Impact:
The fix is straightforward:
The Rust code just needs to use character-aware slicing (
str::floor_char_boundary()orchar_indices()) instead of raw byte indexing. This is a well-documented UTF-8 handling pattern.My concern:
This issue has been reported multiple times (#14310, #15268, #15394, etc.) but remains unfixed. For a paid product, basic Unicode support should be a priority, not an edge case.
Could we please get an ETA on when this will be addressed?
Thank you.
As a CJK user, this is honestly pretty frustrating. Even when using the official ralph-loop to develop the application, the real problem isn’t whether ralph-loop finishes its job — it’s that Claude Code just crashes outright. Ralph seems perfectly capable of getting things done, but Claude Code still can’t survive in a CJK environment. It’s a bit ironic that the “assistant” gives up before the loop does.
This issue continues to occur in claude code v2.1.5
And to avoid this problem, I switched to using opencode, but my account got banned, which is truly baffling.
If you can’t do things properly, then don’t prohibit others from doing them—look at OPENAI.
Additional reproduction: Japanese text
Encountered the same UTF-8 boundary panic when editing Japanese text.
Error Message
Context
Environment
This confirms the issue affects Japanese text, adding to the Chinese and Korean reproductions already reported.
FYI: This issue appears to be fixed in v2.1.6!
Changelog: https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md#216
Reference: https://github.com/anthropics/claude-code/issues/14133#issuecomment-2739536291
Hope this helps!
I didn't find it.
The relevant fix in v2.1.6 changelog is:
This addressed the UTF-8 character boundary issue in the syntax highlighting code.
I created a reproduction repository here: https://github.com/takatea/claude-code-utf8-crash-repro
After updating to v2.1.6, the same operation that previously crashed now works correctly.
This Rust panic on UTF-8 boundary is a bug in Claude Code's text processing (likely in the ripgrep or Grep tool integration). Until it's fixed:
Workaround 1 — Use Bash grep instead of the Grep tool:
If the crash happens during search operations, tell Claude to use Bash grep:
Workaround 2 — Set locale explicitly:
Ensure your locale supports CJK characters properly.
Workaround 3 — Avoid inline CJK in tool calls:
The panic occurs when Claude Code's internal text slicer hits a multi-byte UTF-8 boundary (Chinese characters are 3 bytes each in UTF-8). If the crash is reproducible on specific files:
Workaround 4 — Use pipe mode for CJK-heavy tasks:
Pipe mode may handle the text processing differently and avoid the panic path.
Technical note: The panic at
str/mod.rs:833isstr::index— an attempt to index into a string at a non-character boundary. CJK characters in UTF-8 are 3 bytes, and if the indexing logic assumes 1 byte per character, it can land in the middle of a multi-byte sequence.This is a duplicate of #14405, which was fixed as of version 2.1.6.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.