[UTF-8 -> ANSI]
I have CSV Files encoded with ANSI that were reencoded by VSCode in UTF8.
How to come back to ANSI ?
Notepad makes it badly, I have weird symbols coming out. Sublime text and VSCode don't support ANSI.
Thanks
CodePudding user response:
By "ANSI," I assume you mean Windows-1252. You'll want a tool like iconv. There's a Windows implementation called win-iconv, or you can run it from any Unix-like system (including WSL).
To convert from utf-8 to Windows-1252, you'd use:
iconv -f utf-8 -t windows-1252 file.csv > converted.csv
CodePudding user response:
The trick to convert with Notepad is to cut the whole text, then switch the encoding, then paste the whole text back again; otherwise, it just reinterprets the encoded bytes in the new encoding. Cut/paste stores the document in Unicode on the clipboard, and encodes it in the selected encoding when pasted back.
Note that "ANSI" isn't an encoding, but in Windows terminology it is an alias for the active localized encoding. On US Windows it is "Windows-1252" also known as "cp1252", but it can vary with different localizations of Windows. In Notepad on US Windows, Encoding->ANSI is the same as Encoding->Character sets->Western European->Windows-1252.