[BUG] Claude Code corrupts ANSI/CP1252 encoded files by rewriting them as UTF-8

Resolved 💬 2 comments Opened Feb 25, 2026 by Brunosel Closed Feb 25, 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?

Claude Code rewrites files with ANSI (Windows CP1252) encoding as UTF-8 during any file operation (read, edit, or write), corrupting all non-ASCII characters such as accented characters used in Portuguese and other Latin languages.

---

Environment

| Field | Value |
|---|---|
| Claude Code Version | 2.1.56 |
| File Type | .pas (Pascal/Delphi source files) |
| Original Encoding | ANSI / Windows CP1252 |
| Encoding after Claude Code | UTF-8 (without BOM) |

---

What Should Happen?

Claude Code should detect the original encoding of the file and preserve it when writing back. If the file was ANSI/CP1252, it should be saved as ANSI/CP1252.

Error Messages/Logs

Steps to Reproduce

  1. Create or open a .pas file encoded as ANSI/CP1252 (e.g., generated by Delphi IDE on Windows)
  2. The file contains Portuguese accented characters: á é í ó ú à è ì ò ù ã õ â ê î ô û ç ü (uppercase variants too)
  3. Ask Claude Code to perform any operation on the file (read, edit a line, add a comment, etc.)
  4. Claude Code rewrites the file as UTF-8
  5. Open the file in Notepad++ or Delphi IDE — all accented characters are now corrupted (?? or � replacement characters)

---

Claude Model

Sonnet (default)

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.1.56

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

Windows Terminal

Additional Information

_No response_

View original on GitHub ↗

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