Save file with ANSI encoding in VS Code

10,980

Check out the upcoming VSCode 1.48 (July 2020) browser support.

It also solves issue 33720, where you had to force encoding for the full project before with, for instance:

"files.encoding": "utf8",
"files.autoGuessEncoding": false

Now you can set the encoding file by file:

Text file encoding support

All of the text file encodings of the desktop version of VSCode are now supported for web as well.

https://im4.ezgif.com/tmp/ezgif-4-af94752f0c33.gif

As you can see, the encoding list includes ISO 8859-1, which is the closest norm of what "ANSI encoding" could represent.
The Windows codepage 1252 was created based on ISO 8859-1 but is not completely equal.
It differs from the IANA's ISO-8859-1 by using displayable characters rather than control characters in the 80 to 9F (hex) range

From Wikipedia:

Historically, the phrase "ANSI Code Page" was used in Windows to refer to non-DOS encodings; the intention was that most of these would be ANSI standards such as ISO-8859-1.

Even though Windows-1252 was the first and by far most popular code page named so in Microsoft Windows parlance, the code page has never been an ANSI standard.

Microsoft explains, "The term ANSI as used to signify Windows code pages is a historical reference, but is nowadays a misnomer that continues to persist in the Windows community."

Share:
10,980

Related videos on Youtube

bluppfisk
Author by

bluppfisk

PHP, Symfony, Python, JavaScript. Looking to learn more about all things computer science.

Updated on September 16, 2022

Comments

  • bluppfisk
    bluppfisk over 1 year

    I have a text file that needs to be in ANSI mode. It specifies only that: ANSI. Notepad++ has an option to convert to ANSI and that does the trick.

    In VS Code I don't find this encoding option. So I read up on it and it looks like ANSI doesn't really exist and should actually be called Windows-1252.

    However, there's a difference between Notepad++'s ANSI encoding and VS Code's Windows-1252. It picks different codepoints for characters such as an accented uppercase e (É), as is evident from the document.

    When I let VS Code guess the encoding of the document converted to ANSI by Notepad++, however, it still guesses Windows-1252.

    So the questions are:

    • Is there something like pure ANSI?
    • How can VS Code convert to it?