How can I make all these letters appear correctly?
I can think of two options :
- Convert the file to UTF-8. – This is what I recommend.
- 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.
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
"Western (Windows 1252) Guessed from content" as its
^ 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
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.
(comma) and paste or type
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. 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
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.
||Slavic languages – Latin alphabet (e.g. Polish)
||Slavic languages – Cyrillic alphabet (e.g. Ukrainian)
||Western European languages (French, German, Scandinavian, Spanish, Swahili …)
||Turkish, Latin Azeri, and Latin Uzbek
||Arabic, Farsi, Urdu
||Baltic languages: Estonian, Latvian, Lithuanian
For a list of what "ANSI" could mean, see the table in Section 3.
On macOS, press ⌘ instead of Ctrl.
For Linux users, "ANSI" typically means Windows-1252 – just as on
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.
See the default settings in VS Code.