claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

Character Encoding Handling Fails for WINDOWS-1252 ADVPL Files

Open andrelanzieri opened this issue 5 months ago • 16 comments

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: á, é, í, ç, ã.

andrelanzieri avatar Jul 12 '25 18:07 andrelanzieri

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

arvanus avatar Sep 04 '25 01:09 arvanus

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.

lbresler avatar Sep 09 '25 23:09 lbresler

I have the same problem with Delphi too.

devslimbr avatar Sep 12 '25 21:09 devslimbr

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

robbert-ef avatar Sep 26 '25 07:09 robbert-ef

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

devslimbr avatar Sep 26 '25 12:09 devslimbr

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

pfaustinom1 avatar Sep 29 '25 12:09 pfaustinom1

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 ?

lbresler avatar Oct 07 '25 16:10 lbresler

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.

devslimbr avatar Oct 07 '25 19:10 devslimbr

If you could share the script, I would appreciate it

4brunu avatar Oct 08 '25 06:10 4brunu

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:

Image

robbert-ef avatar Oct 08 '25 06:10 robbert-ef

Here https://github.com/devslimbr/cc-tools

Binary https://github.com/devslimbr/cc-tools/releases

devslimbr avatar Oct 09 '25 00:10 devslimbr

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 :)

ohuet avatar Oct 13 '25 09:10 ohuet

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

devslimbr avatar Oct 13 '25 22:10 devslimbr

Thanks you @devslimbr it works fine for me.

lbresler avatar Oct 16 '25 08:10 lbresler

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

leandrodsilvamg-code avatar Nov 06 '25 07:11 leandrodsilvamg-code

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.

github-actions[bot] avatar Dec 12 '25 10:12 github-actions[bot]

yes, please keep the issue open

arvanus avatar Dec 12 '25 16:12 arvanus