Home  >  Article  >  Development Tools  >  How to write Chinese characters in vscode

How to write Chinese characters in vscode

藏色散人
藏色散人Original
2020-03-31 09:48:594802browse

How to write Chinese characters in vscode

How to write Chinese characters in vscode?

CMD under Chinese windows uses GBK encoding by default. Every time you need it, just enter the command: chcp 65001 in the VSCode terminal, and switch the code page to use UTF-8 to solve the Chinese code The problem is that this method is too troublesome. You have to enter a command every time you enter the terminal. Is there a permanent solution? Of course there is.

Recommended learning: vscode tutorial

Permanently change the console code page to VSCode to 65001:

Open the "File" in VSCode ”--"Preferences"--"Settings", then set it in 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的含义是在运行cmd的时候将编码设置为65001;
>nul是避免在控制台输出修改编码的信息,否则会输出active code page: 65001;

At the same time, give away two easter eggs, for example:

editor.fontSize: 20(修改字体大小为 20);
terminal.integrated.fontFamily:"Courier New"(字体修改为 "Courier New").

You can fill this in according to your own needs. Of course, you don’t need to write it if you don’t need it.

If the above method goes wrong, you can try the comment area below

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

Of course, if you can solve it by modifying GBK or UTF-8 on the lower right, there is no need to choose the above Two methods:

How to write Chinese characters in vscode

#I found that if it is changed to UTF-8, it is normal to run through Run Code, but when it comes to F5 debugging, the black box that pops up is garbled. , if it is changed to GBK, then F5 debugging will be normal and Run Code will be garbled. Anyway, you cannot have both. You can choose for yourself. To sum up, the Run Code operation is changed to UTF-8, and the F5 debugging operation is changed to GBK. Of course, this is not absolute. You also need to take a look at what is modified in "terminal.integrated.shellArgs.windows".

The above is the detailed content of How to write Chinese characters in vscode. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:How to initialize vscodeNext article:How to initialize vscode