Skip to content

[BUG] Write tool corrupts UTF-8 encoding (BOM loss) #13363

Description

@StephFleury

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

Tool affected: Write

Environment: Windows, ASP.NET project (Visual Studio 2026)

Issue: When using the Write tool to completely rewrite a file, UTF-8 BOM (Byte Order Mark) is not preserved. This causes accented characters to display incorrectly (e.g., "sécurisé" becomes "sécurisé").

Expected behavior: Write tool should detect and preserve the original file's encoding (including BOM) when overwriting.

What Should Happen?

This causes accented characters to display incorrectly (e.g., "sécurisé" becomes "sécurisé")

Error Messages/Logs

Steps to Reproduce

Reproduction:

  1. Have a file with UTF-8 BOM encoding containing accented characters (common in .ascx, .aspx, .cs files)
  2. Use Write tool to rewrite the entire file
  3. Accented characters are corrupted

Claude Model

None

Is this a regression?

No, this never worked

Last Working Version

No response

Claude Code Version

2.0.61

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Windows Terminal

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:toolsbugSomething isn't workinghas reproHas detailed reproduction stepsplatform:windowsIssue specifically occurs on WindowsstaleIssue is inactive

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions