Permanently solve the Chinese garbled problem of vscode terminal

Time:2020-9-30

Using vscode to compile and run under windows, there is a problem of Chinese garbled code. Today I met this situation. After searching the Internet for a long time, I didn’t find the correct solution. Now I will show my method

In Chinese windows, the code of GBK is used by default. Every time you need to enter the command: CHCP 65001 at the vscode terminal, you can solve the problem of Chinese code by switching the code page to using UTF-8. However, this method is too troublesome. You have to input the command every time you enter the terminal. Is there any permanent solution? Of course.

The console code page that is permanently modified to vscode is 65001:

In vscode, open file, preferences, settings, and then setting.json Copy the following three lines into it:


{
  "editor.fontSize": 18,
  "terminal.integrated.shellArgs.windows": ["/K chcp 65001 >nul"],
  "terminal.integrated.fontFamily": "Lucida Console",
}

/K CHCP 65001 > nul means that the code is set to 65001 when running CMD;

>Nul is to avoid outputting the information of modifying the code on the console, otherwise the active code page: 65001 will be output;

At the same time, give two colored eggs, such as:

editor.fontSize : 20 (change the font size to 20);

terminal.integrated.fontFamily : “Courier New”

This can be filled in according to your own needs, of course, if you don’t need it, you can leave it blank.

If the above method is wrong, you can try the comments below


"terminal.integrated.shellArgs.windows": ["-NoExit", "/c", "chcp 65001"]

Of course, if you can solve this problem by modifying GBK or UTF-8 at the bottom right, there is no need to choose the above two methods:

It is found that if UTF-8 is changed to UTF-8, it is normal to run through run code. However, when F5 is debugged, the black box pop-up is garbled. If it is changed to GBK, F5 debugging is normal, and run code is garbled. Anyway, you can’t have both. You can choose by yourself. To sum up, run code is changed to UTF-8, F5 debugging run is changed to GBK. Of course, this is not absolute. We need to have a look“ terminal.integrated.shellArgs . windows “what is modified if” terminal.integrated.shellArgs . windows “is not filled in. It seems to be changed to GBK.

This article on the permanent resolution of vscode terminal Chinese garbled problem introduced here, more related vscode terminal Chinese garbled content please search the previous articles of developeppaer or continue to browse the related articles below, I hope you will support developeppaer more in the future!