[BUG] Edit/Write tool corrupts accented characters in Windows-1252 (cp1252)

Open 💬 3 comments Opened Jun 2, 2026 by sygecom

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?

What's wrong: The Edit/Write tools read and write files as UTF-8 with no way to specify the file's actual encoding. When editing a Windows-1252 file containing accented characters (ç, ã, õ, etc. — common in pt-BR codebases), the tool fails to decode the cp1252 bytes (e.g. 0xE7, 0xE3), replaces them with U+FFFD, and writes the whole file back in UTF-8 — corrupting every accent in the file, not just the edited lines. The VS Code files.encoding setting does not help because Edit/Write bypasses the editor's encoding engine.

What Should Happen?

Impact: Makes Edit/Write unusable on large legacy codebases in cp1252 (e.g. xHarbour/Clipper ERP systems). Forces a manual diff-and-apply workflow or external Python scripts for every edit.

Error Messages/Logs

Steps to Reproduce

Request: Add per-file or per-glob encoding configuration (e.g. respect .editorconfig, or a setting like files.encoding honored by Edit/Write), or auto-detect and preserve the file's existing encoding on write instead of forcing UTF-8.

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.1.158 (Claude Code)

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

VS Code integrated terminal

Additional Information

_No response_

View original on GitHub ↗

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