Search code examples
visual-studio-codecodepages

VS Code terminal not using same codepage as VS Code editor


How do I tell VS Code terminal to use same codepage as Editor?

This code:

class Program {
  static void Main(string[] args) {
    WriteLine("æøå;ÆØÅ");
  }
}

(encoded in UTF-8 with BOM) outputs æoå;ÆOÅ instead of æøå;ÆØÅ when run with dotnet run in the VS Code terminal. (Notice the ø and Ø are rendered as o and O.)

Screen shot: VS Code editor end terminal:

I tried chcp 1252 in the terminal but it made no difference.

How can I adjust the terminal settings to display the text correctly, with the right code page?


Solution

  • It's just like that. I'm pretty sure VS Code tries to detect encoding (you can also specify manually), but what happens in the terminal is not really in VS Code's jurisdiction so to speak (at least- not by default).

    Switch your terminal/console's code page to UTF-8 by using the chcp.com 65001 command in it (or chcp 65001. the .com might be optional).

    Related readings: