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

Resolved 💬 6 comments Opened Dec 8, 2025 by StephFleury Closed Feb 28, 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?

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_

View original on GitHub ↗

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