-1

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?

starball
  • 20,030
  • 7
  • 43
  • 238
  • There is still some information missing, though: what encoding is your source code in? I believe VSCode will use utf-8 by default, but you can find the information in the bottom right corner of your VSCode window, in the status bar. I can tell you by experience that encodings on Windows are a constant source of trouble. I always use utf-8, but that's not the default in Powershell or Cmd. I solve that problem by using Git Bash instead, but hopefully someone with Powershell experience will be able to help you. – joanis May 13 '23 at 15:02
  • 1
    please also see [this question](https://stackoverflow.com/q/76039517/11107541), the duplicate it points to, and the chatroom linked in its comments. What code page is your terminal/console using? Show us the output of running `chcp.com`. If you want utf-8 codepage, run `chcp.com 65001`. – starball May 13 '23 at 20:20
  • PS D:\NAS\IT\C#\CoreCode\Temp> chcp Active code page: 437 PS D:\NAS\IT\C#\CoreCode\Temp> – Jan Andersen May 14 '23 at 07:15

1 Answers1

1

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:

starball
  • 20,030
  • 7
  • 43
  • 238