[BUG] Rust panic when handling Arabic text - byte index not on char boundary
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?
Claude Code crashes (panics) when processing Arabic text in code comments or console output. The Rust code is indexing into a UTF-8 string at a byte position that falls in the middle of a multi-byte Arabic character, causing an immediate panic and complete crash of the CLI.
What Should Happen?
Claude Code should handle multi-byte UTF-8 characters (Arabic, Chinese, Hebrew, Persian, etc.) correctly without crashing. The string slicing should use character boundaries, not byte boundaries.
Error Messages/Logs
thread '<unnamed>' panicked at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/str/mod.rs:833:21:
byte index 7 is not a char boundary; it is inside 'ر' (bytes 6..8) of 'state تقرير (من الـ'
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
- Open a React/TypeScript project
- Edit a JavaScript file containing Arabic text in console.log:
console.log('✅ تم تحديث الملاحظة في الـ state:', { observationId, updates });
- Let Claude Code process and display the changes
- Claude Code crashes immediately when trying to slice/display the Arabic string
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.0.76
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
This is a UTF-8 string slicing bug in Rust. Arabic characters use 2 bytes each in UTF-8 encoding. The code attempts to slice at byte index 7, which falls in the middle of the Arabic character 'ر' (bytes 6-8).
This issue affects:
- Arabic speakers
- Hebrew speakers
- Persian/Farsi speakers
- Urdu speakers
- Potentially Chinese, Japanese, Korean users
The fix should use Rust's .chars() iterator or .char_indices() instead of direct byte indexing when slicing strings that may contain non-ASCII characters.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗