Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Microsoft Visual Studio 2022 debug Console cannot display correctly chinese

I really didn't expect that the visual studio 2022 version could not display Chinese correctly! I used JetBrains Rider before. It has a built-in console. When running, it will always display Chinese correctly, just like VSCode's built-in terminal.

I know it must be because the character code the code is running on doesn't match the terminal's settings. But this should not be manually modified by the user. . .

my code:

Console.WriteLine("Hello World!");
// here does not work
// output: ??,??!
Console.WriteLine("你好,世界!");

output: console output

extra information:

  • my operating system: windows 10
  • windows terminal as defautl terminal
  • Visual Studio uses "windows console host" as the default console, it doesn't seem to support utf-8. (I have set windows terminal as default terminal)
  • When I set the default terminal to "Windows Console Host", right-click to view the character encoding of the terminal: Windows console host character encoding of the console

Maybe replacing the default console of visual studio with powershell can solve the problem?


thank you all

like image 594
Lorenzo Yang Avatar asked Oct 31 '25 13:10

Lorenzo Yang


1 Answers

I found a temporary solution (as one line of code needs to be added):

In my case (windows 10), Visual Studio uses a console called "Windwos Console Host" as the default terminal, which doesn't seem to support utf-8

because when I added the following code:

Console.OutputEncoding = Encoding.UTF8;

the Chinese output changed from "question mark" to "strange symbols", so I deduce that the terminal used by Visual Studio Debug Console probably does not support UTF-8:

console output

So I changed the default terminal to "windows terminal" in the settings of "windows terminal":

windows terminal setting

This time successfully printed Chinese ("windows terminal" must support utf-8):

console output

like image 107
Lorenzo Yang Avatar answered Nov 03 '25 23:11

Lorenzo Yang



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!