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.

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."

Answer from VonC on Stack Overflow
🌐
GitHub
github.com › microsoft › vscode › issues › 92240
Support ANSI encoding · Issue #92240 · microsoft/vscode
March 8, 2020 - feature-requestRequest for new features or functionalityRequest for new features or functionalityfile-encodingFile encoding type issuesFile encoding type issuesinfo-neededIssue requires more information from posterIssue requires more information from poster ... We need ANSI encoding for Visual Studio Code by default.
Author: microsoft
Discussions

Auto detect ANSI encoding
VSCode Version: 1.1.1 OS Version: Win 10 Steps to Reproduce: Create a new file in notepad, save it as ANSI (on my machine Ansi = Windows-1252) Open the file in vs code Result: VSCode assumes UTF-8 ... More on github.com
🌐 github.com
11
May 31, 2016
Visual Studio Code distorts ANSI characters
I have problems with Swedish national characters in Visual Studio Code. It can be shown with the following program: fn main() { let abc = " ååå ööö äää"; println!(" ", abc); } When I run the program in Rust Playground, I get the following output: When the program is run from the command ... More on users.rust-lang.org
🌐 users.rust-lang.org
8
0
December 3, 2022
Running ANSI C in VSCode Windows
First. In my opinion, C89 is TRASH. Don't learn that archaic junk. C99 at minimum. Second, I believe the C/C++ extension settings only effect how intelli-sense parses and makes suggestions in your code. It does not effect your build tasks because those are a separate feature from the C/C++ extension. Ultimately the build task runs arbitrary commands on your system and it's up to you to configure them appropriately (the extension does offer templates to get you started). More on reddit.com
🌐 r/learnprogramming
5
1
December 28, 2021
visual studio code - CSV Files ANSI encoded was reencoded by VSCode in UTF8. How to come back to ANSI? - Stack Overflow
[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 V... More on stackoverflow.com
🌐 stackoverflow.com
Top answer
1 of 2
9

How can I make all these letters appear correctly?

I can think of two options :

  1. Convert the file to UTF-8. – This is what I recommend.
  2. Configure VS Code to auto-detect the most proper encoding.

The second option is preferable if you never want to change the encoding of any files.

Option 1. Convert the file to UTF-8

The acronym ANSI stands for American National Standards Institute.

The problem with ANSI encoding is that – although the name suggests that it's following a standard – it is conditional on what natural language the text is written in.
In the case of Western European (Latin) languages, "ANSI" encoding means the code page Windows-1252. 1

1a. Make VS Code use the correct encoding

In VS Code, instead of looking for ANSI encoding, look for Windows-1252.
I clicked UTF-8 > Reopen with Encoding, and VS Code displayed
"Western (Windows 1252) Guessed from content" as its top suggestion.

^ click to enlarge

VS Code correctly guessed the encoding Windows 1252.
If you don't want to change the encoding, you're now all set and done.

Otherwise, it remains to convert the file to UTF-8 encoding.

1b. Convert to UTF-8

The status bar now displays Windows 1252 instead of UTF-8.
Click on Windows 1252 and then on Save with Encoding :

Now click on "UTF-8 utf8" :

This converts the file's non-ASCII characters to UTF-8 and encodes the file as UTF-8.

Option 2. Configure VS Code to auto-detect the encoding

If you don't want to convert to UTF-8, and if you experience this problem every time you open another file – you may prefer to set VS Code to always auto-guess the encoding.

To achieve this, you need to enable the Auto Guess Encoding feature of VS Code.
Press Ctrl+, 2 (comma) and paste or type autoGuessEncoding. Check the box where it says :
"When enabled, the editor will attempt to guess the character set encoding when opening files. This setting can also be configured per language. Note, this setting is not respected by text search. Only Files: Encoding is respected." 3

3. The confusion about what "ANSI" encoding means

Searching the internet to find out what "ANSI" means in the context of encoding may cause confusion.
You might encounter that ANSI is "a misnomer", which is true but, not of much practical help.

What clears up the confusion is to realize that when Microsoft writes "ANSI" in the status bar of notepad.exe, it typically means Windows-1252. For natural languages other than Western European, see the table below.
Other well-known text editors, such as Notepad++, have adopted this convention and also write "ANSI" in the status bar.

Windows-1252 is sometimes called code page 1252 or CP-1252. Likewise for the other code pages.

ANSI encoding Language/Alphabet
Windows-1250 Slavic languages – Latin alphabet (e.g. Polish)
Windows-1251 Slavic languages – Cyrillic alphabet (e.g. Ukrainian)
Windows-1252 Western European languages (French, German, Scandinavian, Spanish, Swahili …)
Windows-1253 Greek
Windows-1254 Turkish, Latin Azeri, and Latin Uzbek
Windows-1255 Hebrew
Windows-1256 Arabic, Farsi, Urdu
Windows-1257 Baltic languages: Estonian, Latvian, Lithuanian
Windows-1258 Vietnamese
Windows-1270 Sami languages

References

  • "ANSI" stands for American National Standards Institute
  • Character sets listed by language
  • The code page Windows-1270 | Sami languages
  • Microsoft official encoding information
  • Windows code pages | Wikipedia
  • Macintosh emulation code pages | Wikipedia
  • The default settings in VS Code
  • Wikipedia refers to ANSI encoding as "a misnomer"
  • Download page for Notepad++

1 For a list of what "ANSI" could mean, see the table in Section 3.

2 On macOS, press ⌘ instead of Ctrl. For Linux users, "ANSI" typically means Windows-1252 – just as on Windows.
For macOS users, try to see what VS Code suggests as Guessed from content.
Or else have a look at Macintosh emulation code pages at Wikipedia.

3 See the default settings in VS Code.

2 of 2
0

Click on UTF-8 and select Windows 1252 or ISO 8859-1. Both will work in this case if it's only å, ä and ö that is the problem. You can then choose "Save with Encoding" which should open the file with the correct codec next time in my experience.

🌐
GitHub
github.com › microsoft › vscode › issues › 7048
Auto detect ANSI encoding · Issue #7048 · microsoft/vscode
May 31, 2016 - VSCode Version: 1.1.1 OS Version: Win 10 Steps to Reproduce: Create a new file in notepad, save it as ANSI (on my machine Ansi = Windows-1252) Open the file in vs code Result: VSCode assumes UTF-8 and the file is corrupted. Sublime-text ...
Author: microsoft
🌐
W3Schools
w3schools.io › editor › vscode-encoding
Visual studio code Change encoding for single files and Permanently - w3schools
December 31, 2023 - how to change the VSCode encoding to (UTF-8, UTF-16, ANSI, ISO-8859-1, Arabic, Japanese), a single file for reopening ,set global encoding permanently
🌐
Rust Programming Language
users.rust-lang.org › help
Visual Studio Code distorts ANSI characters - help - The Rust Programming Language Forum
December 3, 2022 - I have problems with Swedish national characters in Visual Studio Code. It can be shown with the following program: fn main() { let abc = " ååå ööö äää"; println!(" ", abc); } When I run the program in Rust Playground, I get the following output: When the program is run from the command line using "cargo run", the output is as follows: Strangely, spaces are added at the beginning of lines 2 and 3. However, when the program is...
🌐
Reddit
reddit.com › r/learnprogramming › running ansi c in vscode windows
r/learnprogramming on Reddit: Running ANSI C in VSCode Windows
December 28, 2021 -

Hey all, I'm currently working as a frontend web dev, but over the xmas holidays I thought I would learn C, since it's not supposed to be a big language and I thought it might be fun (and useful, in the long run). I got "The C Programming Language Second Edition" by Brian Kernighan & Dennis Ritchie. It's quite an old book which teaches you ANSI C (C89). I downloaded MinGW and the VSCode C/C++ extension.

The only way I can compile and run my hello_world.c file as C89 is by manually adding "-ansi", in the tasks.json file in the args list. But I should be able to set C89 as the default under the C/C++ extension settings. There is a setting I can see which says

C_Cpp > Default C Standard

The default value to use in a configuration if cStandard is either not specified or set to ${default}.

So I select "gnu89" from the dropdown, then when click "Run Build Task..." it compiles it with a more modern spec of C, not what I wanted. Can anyone help me out with this? The setting seems to do nothing.

Also, even when I add "-ansi" to the build task, running the code with Code Runner ignores it and compiles it to a more modern spec of C before running it. I know because I'm getting errors which shouldn't be a problem in C89.

Any help would be super appreciated!

🌐
Stack Overflow
stackoverflow.com › questions › 69287742 › csv-files-ansi-encoded-was-reencoded-by-vscode-in-utf8-how-to-come-back-to-ansi
visual studio code - CSV Files ANSI encoded was reencoded by VSCode in UTF8. How to come back to ANSI? - Stack Overflow
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.
Find elsewhere
🌐
Developer Community
developercommunity.visualstudio.com › content › problem › 757607 › automatic-ansi-rc-file-conversion-to-utf8-not-want.html
Automatic ANSI .rc file conversion to UTF8 !!! (not wanted !!!)
October 2, 2019 - Skip to main content · Visual Studio · Guidelines Problems Suggestions Code of Conduct · Downloads · Visual Studio IDE Visual Studio Code Azure DevOps Team Foundation Server Accounts and Subscriptions · Subscriber Access · Microsoft Security Azure Dynamics 365 Microsoft 365 Microsoft ...
🌐
Visual Studio Marketplace
marketplace.visualstudio.com › items
ANSI Colors - Visual Studio Marketplace
Extension for Visual Studio Code - ANSI color styling for text documents
🌐
Developer Community
developercommunity.visualstudio.com › content › problem › 107929 › how-to-change-utf-8-to-ansi-or-unicode.html
How to change utf-8 to ansi or Unicode - Developer Community
September 6, 2017 - Skip to main content · Visual Studio · Guidelines Problems Suggestions Code of Conduct · Downloads · Visual Studio IDE Visual Studio Code Azure DevOps Team Foundation Server Accounts and Subscriptions · Subscriber Access · Microsoft Security Azure Dynamics 365 Microsoft 365 Microsoft ...
🌐
GitHub
github.com › microsoft › vscode › issues › 232273
Issue · microsoft/vscode
October 25, 2024 - Many older compilers use ANSI encoding as the default saving format for code files, and comments are also saved as ANSI encoding, hoping that vscode will be compatible with ANSI encoding to make the code more readable.
Author: microsoft
🌐
GitHub
github.com › microsoft › vscode › issues › 168803
files.autoGuessEncoding not working for ANSI encoded file · Issue #168803 · microsoft/vscode
December 11, 2022 - Do not open test file with VSCode, instead create a blank *.test file in VSCode and save it with ISO 8859-1 encoding · Copy downloaded file contents (from notepad) into created file in VSCode and make sure it's saved with ISO 8859-1 · You ...
Author: microsoft
🌐
Developer Community
developercommunity.visualstudio.com › t › vs-saves-files-without-bom-as-ansi-instead-of-utf › 364271
VS saves files without BOM as ANSI instead of UTF-8
Skip to main content · Visual Studio · Guidelines Problems Suggestions Code of Conduct · Downloads · Visual Studio IDE Visual Studio Code Azure DevOps Team Foundation Server Accounts and Subscriptions · Subscriber Access · Microsoft Security Azure Dynamics 365 Microsoft 365 Microsoft ...
🌐
Developer Community
developercommunity.visualstudio.com › t › Prefer-UTF-8-to-ANSI-encoding-in-Markdow › 10966563
Prefer UTF-8 to ANSI encoding in Markdown files that ...
Skip to main content · Visual Studio · Guidelines Problems Suggestions Code of Conduct · Downloads · Visual Studio IDE Visual Studio Code Azure DevOps Team Foundation Server Accounts and Subscriptions · Subscriber Access · Microsoft Security Azure Dynamics 365 Microsoft 365 Microsoft ...
🌐
GitHub
github.com › microsoft › vscode › issues › 52642
Non-standard ascii character changed to unicode � in ANSI file · Issue #52642 · microsoft/vscode
June 21, 2018 - It saves the question mark character (�) in unicode, which is interpreted as three characters instead of one inside other applications that only read ANSI. ... VS Code version: Code - Insiders 1.25.0-insider (7dc9539, 2018-06-15T05:17:41.405Z) OS version: Windows_NT x64 10.0.15063 ... 2d_canvas: enabled checker_imaging: disabled_off flash_3d: enabled flash_stage3d: enabled flash_stage3d_baseline: enabled gpu_compositing: enabled multiple_raster_threads: enabled_on native_gpu_memory_buffers: disabled_software rasterization: enabled video_decode: enabled video_encode: enabled webgl: enabled webgl2: enabled
Author: microsoft
🌐
Stack Overflow
stackoverflow.com › questions › 72647899 › how-to-fix-ansi-colors-encoding-in-vscode-git-log
visual studio code - How to fix ANSI colors encoding in VSCode Git Log? - Stack Overflow
June 16, 2022 - Got same issue with BiomeJS + lefthook in VSCode. Only workaround I could find was to disable colorization with --colors=off. I've also tried the plugin "ANSI colors" but I could not get it automatically applied on git/Biome output.
🌐
Visual Studio Code
code.visualstudio.com › updates › v0_3_0
June 2015 (0.3.0)
November 3, 2021 - Set the file encoding globally or per workspace by using the files.encoding setting in User Settings or Workspace Settings.
🌐
GitHub
github.com › Microsoft › vscode › issues › 67571
Encoding Files Problem · Issue #67571 · microsoft/vscode
January 30, 2019 - Anybody has an idea on why vs is creating files on ANSI instead of UTF-8?? I noticed this problem when I was trying to load a js file, it said the first character was invalid, but the code was fine... then I checked into the encoding and it was ANSI... saved the file as UTF-8 using notepad and the problem went away...
Author: microsoft
🌐
Developer Community
developercommunity.visualstudio.com › t › GitHub-Copilot-creates-new-files-with-AN › 10953370
GitHub Copilot creates new files with ANSI encoding ...
Skip to main content · Visual Studio · Guidelines Problems Suggestions Code of Conduct · Downloads · Visual Studio IDE Visual Studio Code Azure DevOps Team Foundation Server Accounts and Subscriptions · Subscriber Access · Microsoft Security Azure Dynamics 365 Microsoft 365 Microsoft ...