Skip to content

Write tool corrupts UTF-8 multi-byte characters (box-drawing chars become NULL bytes) #13080

Description

@nazmulidris

Summary

The Write tool corrupts UTF-8 multi-byte characters by stripping the high bytes, leaving only the low byte of each Unicode codepoint. This results in files that appear as "binary" and cannot be opened in text editors.

Environment

  • OS: Linux 6.17.0-7-generic
  • Claude Code: VS Code extension

Steps to Reproduce

  1. Ask Claude to write a file containing Unicode box-drawing characters:

    Write a markdown file with box-drawing characters like ─ │ ┌ ┐ └ ┘
    
  2. Try to open the resulting file in VS Code, bat, micro, or other text editors

  3. Editors report the file is binary or has unsupported encoding

Expected Behavior

Box-drawing character ─ (U+2500) should be encoded as 3-byte UTF-8: e2 94 80

Actual Behavior

The character is written as a single byte 00 (just the low byte of the codepoint)

Hex dump comparison:

Corrupted file (written by Write tool):

7c 20 60 00       60 20 7c   →  | `.` |   (NULL byte!)
         ^^ ^^ ^^

Correct file (copy-pasted from Claude's stdout):

7c 20 60 e2 94 80 60 20 7c   →  | `─` |   (proper UTF-8)
         ^^ ^^ ^^

Pattern

The corruption consistently strips UTF-8 encoding, keeping only codepoint & 0xFF:

Character Unicode Expected UTF-8 Actual Byte
─ U+2500 e2 94 80 00
│ U+2502 e2 94 82 02
┌ U+250C e2 94 8c 0c
┐ U+2510 e2 94 90 10
└ U+2514 e2 94 94 14
┘ U+2518 e2 94 98 18

Workaround

Copy-paste Claude's stdout output to a file manually instead of using the Write tool.

Impact

  • Files containing emoji, CJK characters, box-drawing, or any non-ASCII Unicode will be corrupted
  • Affected files cannot be opened in standard text editors
  • No warning is given that corruption occurred

Activity

  1. github-actions commented on Dec 4, 2025

    @github-actions

    Found 3 possible duplicate issues:

    1. Unicode Codepoint Corruption During Write Operation #6903
    2. [BUG] UTF-8 Corruption Bug #1716
    3. [BUG] Write tool write garbled text when write emojis to empty file - 100% reproduce #7558

    This issue will be automatically closed as a duplicate in 3 days.

    • If your issue is a duplicate, please close it and 👍 the existing issue instead
    • To prevent auto-closure, add a comment or 👎 this comment

    🤖 Generated with Claude Code

  2. scpedicini commented on Dec 6, 2025

    @scpedicini

    Experiencing this issue as well. This corruption resulting in weird control chars / null bytes also started happening VERY consistently whenever Claude edits an empty markdown file.

  3. github-actions commented on Jan 6, 2026

    @github-actions

    This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

  4. xrchz commented on Jan 12, 2026

    @xrchz

    This issue is part of a larger UTF-8/encoding bug pattern affecting Claude Code's Edit/Write tools.

    I've posted a consolidated impact analysis at #13939 showing at least 6+ related issues spanning 6+ months. The technical analysis you provided here (showing codepoint & 0xFF truncation) is particularly valuable for debugging.

    Cross-linking for visibility: #13939, #7134, #7332, #7335

    This affects all non-English users and should be prioritized.


    🤖 Generated with Claude Code

  5. github-actions commented on Feb 12, 2026

    @github-actions

    This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.

  6. github-actions commented on Feb 20, 2026

    @github-actions

    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.

  7. locked as resolved and limited conversation to collaborators on Feb 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:toolsbugSomething isn't workinghas reproHas detailed reproduction stepsplatform:linuxIssue specifically occurs on Linux

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions