Character Encoding Handling Fails for WINDOWS-1252 ADVPL Files

Resolved 💬 19 comments Opened Jul 12, 2025 by andrelanzieri Closed Jan 14, 2026

I work with a language called ADVPL from the Protheus ERP. The programs used (with .prw and .tlpp extensions) have WINDOWS-1252 encoding. Claude can even edit them, but it replaces the accented characters with special characters. This is likely because it is editing them as UTF-8 files, corrupting the file and replacing the characters with special ones, for example: á, é, í, ç, ã.

View original on GitHub ↗

19 Comments

arvanus · 10 months ago

I have the same problem, with Delphi ANSI .pas files

lbresler · 10 months ago

Same problem with php files in latin1.
It seems that Claude Code can only open file sin UTF-8. It would be great that it respect the charset of the files.

devslimbr · 10 months ago

I have the same problem with Delphi too.

robbert-ef · 9 months ago

Same problem here, even when I instruct Claude to use Windows-1252 encoding trough CLAUDE.md

devslimbr · 9 months ago

While Code Claude does not have a native alternative, I created a CLI in GO that edits files respecting the file format, and I made this instruction from CLAUDE.md

pfaustinom1 · 9 months ago

I'm facing the same issue with Windows-1252 encoding being modified by Claude to UTF-8.

lbresler · 9 months ago
While Code Claude does not have a native alternative, I created a CLI in GO that edits files respecting the file format, and I made this instruction from CLAUDE.md

Can you please provide more informations ?

Perhaps is it possible to manage this issue with a MCP ?

devslimbr · 9 months ago
> While Code Claude does not have a native alternative, I created a CLI in GO that edits files respecting the file format, and I made this instruction from CLAUDE.md Can you please provide more informations ? Perhaps is it possible to manage this issue with a MCP ?

It’s a command-line tool (CLI) where I specify the file name and the encoding type. By default, it automatically reads and writes the content.
In the CLAUDE.md file, I explain that any file creation or editing should use this tool, and I describe its parameters there.
When editing occurs, Claude uses this CLI tool.
The issue is that Claude Code uses UTF-8 by default, but not all files are encoded that way — and the problem lies in its native editing tool.

If people are interested, I can release the code as open source, since to me, this would be an easy fix that Anthropic could have implemented natively.

4brunu · 9 months ago

If you could share the script, I would appreciate it

robbert-ef · 9 months ago

I've managed to fix this by modifiyng %APPDATA%\npm\node_modules\@anthropic-ai\claude-code\cli.js and changing the default encoding to latin1.
There is a function which determines the file encoding by inspecting the BOM and falls back to utf8.
Search for utf16le and replace the fallback return values to latin1:

<img width="1196" height="156" alt="Image" src="https://github.com/user-attachments/assets/adf0ed75-5d17-4484-bd00-0af6e43dd0d7" />

ohuet · 9 months ago

Great !
Could you please add, inside the Installation section of the README.md, what you've wrote in the CLAUDE.md ?
Because I'm not really sure what to tell him '^^
Thanks in advance :)

devslimbr · 9 months ago

CLAUDE.md example.
In this example, I added cctools to the Windows environment variable.
If it’s copied to a project, you’ll need to change ./cctools.

prompt.txt

lbresler · 9 months ago

Thanks you @devslimbr it works fine for me.

leandrodsilvamg-code · 8 months ago

It's much easier for Claude AI to solve this than to keep doing hacks.

github-actions[bot] · 7 months ago

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.

arvanus · 7 months ago

yes, please keep the issue open

github-actions[bot] · 6 months ago

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.

github-actions[bot] · 5 months ago

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.