[BUG] Write tool outputs garbled text when writing Chinese

Resolved 💬 2 comments Opened Sep 13, 2025 by tjx666 Closed Sep 13, 2025

Describe the bug

When using the Write tool to create a file containing Chinese poetry (《静夜思》by 李白), the output file contains garbled/corrupted characters instead of the intended Chinese text.

What happened (Actual behavior)

The Write tool was used to write a Chinese poem to /Users/yutengjing/code/lobe-chat-cloud/poem.md. The intended content was:

# 静夜思

唐·李白

床前明月光,
疑是地上霜。
举头望明月,
低头思故乡。

However, the actual file content became corrupted/garbled:

# Y

�N}

�MI
�/0

>4
N4Ea

What should happen (Expected behavior)

The file should contain the properly encoded Chinese text as provided to the Write tool.

Error messages or logs

No error messages were shown. The Write tool reported "File created successfully" despite the corrupted output.

Steps to reproduce

  1. Use Claude Code with the Write tool
  2. Attempt to write Chinese text (or potentially any non-ASCII Unicode text) to a file
  3. The file is created but contains garbled characters

Claude Model

claude-opus-4-1-20250805

Is this a regression?

Unknown - haven't tested with previous versions

Claude Code Version

Latest version (as of 2025-09-13)

API Platform

Desktop

Operating System

macOS Darwin 24.6.0

Terminal/Shell

Cursor IDE integrated terminal

Additional context

  • The issue appears to be an encoding problem with the Write tool
  • The postToolUseChecks.js hook did not detect this corruption
  • This may affect other non-ASCII languages as well
  • The Read tool correctly shows the corrupted content when reading the file back

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗