[BUG] Panic when editing files containing Korean (multi-byte UTF-8) text - byte index not a char boundary
Resolved 💬 3 comments Opened Jan 9, 2026 by hsjin500 Closed Feb 23, 2026
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 with a Rust panic when attempting to edit a file containing Korean text. The error indicates an invalid byte index that falls in the middle of a multi-byte UTF-8 character.
The application aborts completely, requiring a restart.
What Should Happen?
Claude Code should properly handle multi-byte UTF-8 characters (Korean, Chinese, Japanese, etc.) when performing edit operations, without crashing.
Error Messages/Logs
thread '<unnamed>' (222254) panicked at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/str/mod.rs:833:21:
byte index 7 is not a char boundary; it is inside '말' (bytes 5..8) of `\n주말 근무는 8시간까지 1.5배, 초과분은 2배로 인정됩니다.',`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 5, aborting
[1] 21988 abort claude -c
Steps to Reproduce
- Open a Flutter/Dart project with a file containing Korean text strings
- The file contains text like:
```dart
'\n주말 근무는 8시간까지 1.5배, 초과분은 2배로 인정됩니다.'
- Request Claude to edit/update this file (e.g., "add numbered list to the Korean text")
- When Claude attempts to perform the Edit operation, the application panics and aborts
The issue appears to occur during the diff/edit preview stage, possibly when calculating string boundaries for displaying changes.
Claude Model
Opus
Is this a regression?
No, this never worked
Last Working Version
2.1.1 (Claude Code)
Claude Code Version
2.1.2 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
iTerm2
Additional Information
**Root Cause Analysis:**
This is a classic Rust UTF-8 string slicing bug. Korean characters occupy 3 bytes in UTF-8:
- '주' = bytes 1-3
- '말' = bytes 5-8 (with newline at byte 0)
The code attempts to slice at byte index 7, which falls inside the '말' character (bytes 5-8), causing the panic.
**Suggested Fix:**
Use character-aware string operations instead of byte-based slicing:
- `str.chars()` iterator
- `str.char_indices()` for position-aware iteration
- Ensure all string slice indices align with `str.is_char_boundary(index)`
**Affected Use Case:**
Editing source files containing CJK (Chinese, Japanese, Korean) or other multi-byte Unicode characters.This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗