Skip to main content
1 of 5

How can I make all these letters appear correctly?

You have 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 a standard – it's conditional on what natural language your text is written in. In the case of Swedish/Scandinavian, or even all Western European (Latin) languages, "ANSI" means Windows-1252. 1

1a. Make VS Code use the correct encoding

So, in VS Code, instead of looking for ANSI encoding, you should look for Windows-1252.

VS Code correctly guesses on Windows 1252 encoding.

If you don't want to change the encoding, you're now all set and done.

Otherwise, it now 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 :

Click Windows 1252 > Save with Encoding.

Now click on UTF-8. This converts the file's encoding to UTF-8 :

Click on 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 over and over again – every time you open another file, you may prefer to have VS Code always auto-guess the encoding.

To achieve this, you need to enable the Auto Guess Encoding feature of VS Code. Press Ctrl+, and paste or type autoGuessEncoding. 2 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."

Check the box if you want VS Code to auto-guess the encoding.

3. A table showing ANSI encoding → language/alphabet

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 (Afrikaans, French, German, Scandinavian, Spanish, Swahili …)
Windows-1253 Greek
Windows-1254 Turkish, Latin Azeri and Uzbek
Windows-1255 Hebrew
Windows-1256 Arabic, Farsi, Urdu
Windows-1257 Baltic languages: Estonian, Latvian, Lithuanian
Windows-1258 Vietnamese

References


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

2 On macOS, press instead of Ctrl. I honestly don't know how helpful this answer is to macOS users.