claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] UTF-8 Korean string slicing panic - byte index not a char boundary

Open doublek13 opened this issue 4 months ago • 0 comments

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?

Bug Description

Claude Code panics when processing Korean (UTF-8) strings, attempting to slice at byte boundaries that fall in the middle of multi-byte characters.

Error Message

thread '' panicked at /rustc/.../library/core/src/str/mod.rs:833:21: byte index 14 is not a char boundary; it is inside '오' (bytes 12..15) of 서푸르지오 방문예약 fatal runtime error: failed to initiate panic, error 5, aborting

Environment

  • OS: macOS Darwin 24.6.0
  • Claude Code version: 2.0.76
  • Language: Korean (한국어)

Root Cause

Korean characters are 3 bytes each in UTF-8. The code slices at byte index 14, which falls inside '오' (bytes 12-14).

Impact

Makes Claude Code unusable for projects containing Korean text.

What Should Happen?

Claude Code should handle Korean (and all UTF-8 multi-byte characters) correctly without panicking.

Specifically:

  1. String slicing should use character boundaries, not raw byte indices
  2. When processing file paths, content, or session data containing Korean text, Claude Code should work normally
  3. If string truncation is needed, it should use safe UTF-8 aware methods like:
    • str.chars().take(n) instead of &str[..n]
    • str.char_indices() for finding valid slice points

No crashes should occur when working in directories or with files containing non-ASCII characters.

Error Messages/Logs


Steps to Reproduce

  1. Create or open a project directory containing files with Korean text Example: A website project with Korean content like "달서푸르지오 방문예약"

  2. Run Claude Code in that directory: claude

  3. Perform any operation that triggers internal caching/indexing (e.g., reading files, using TodoWrite, or session persistence)

  4. The panic occurs during Claude Code's internal string processing

Alternative reproduction:

  • Work in a directory path containing Korean characters
  • Or have Korean text in file names
  • Or have Korean content that gets cached in ~/.claude/todos/ or ~/.claude/projects/

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

2.0.76

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

VS Code integrated terminal

Additional Information

No response

doublek13 avatar Dec 23 '25 13:12 doublek13