Character Encoding Handling Fails for WINDOWS-1252 ADVPL Files
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: á, é, í, ç, ã.
I have the same problem, with Delphi ANSI .pas files
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.
I have the same problem with Delphi too.
Same problem here, even when I instruct Claude to use Windows-1252 encoding trough CLAUDE.md
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
I'm facing the same issue with Windows-1252 encoding being modified by Claude to UTF-8.
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 ?
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.
If you could share the script, I would appreciate it
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:
Here https://github.com/devslimbr/cc-tools
Binary https://github.com/devslimbr/cc-tools/releases
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 :)
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.
Thanks you @devslimbr it works fine for me.
It's much easier for Claude AI to solve this than to keep doing hacks.
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.
yes, please keep the issue open