Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

The solution of Chinese garbled code in vscode debugging c language

Shulou Source: shulou.com Published: 2022-06-02 16:51:27 09月29日 Update

This article mainly introduces the solution of vscode debugging c language Chinese garbled code, the article is very detailed, has a certain reference value, interested friends must read it!

I have been plagued by the Chinese garbled code of vscode's cUniverse + console for a long time, and some of the methods I found are not suitable for my situation at all, and then I finally found a way to do it. In fact, it is to configure two places.

First of all, the running program of the c language is called cmd.exe, while the cmd code of window defaults to 936, that is, gb2312. Run-> cmd- > right-click in the head of the white window-> attribute can be seen, mainly now use utf-8 more, so the c program encoded with utf-8 appeared garbled.

Modify character encoding in cmd or vscode console

Chcp can view the current console character encoding

You can modify the encoding with chcp 65001, and the following message is displayed indicating that the modification was successful, but it is only useful if it is currently open. The next time you open it, it will be gbk again.

This method can correct the garbled code to see the effect when the code is already utf-8.

1. Cmd console:

Enter the running program directory and run the program. For example, my c program is in d:/c/a.exe. After entering cmd.

D:cd cchcp 65001a.exe

You can output the program in Chinese when the character is encoded as utf-8.

2. Vscode console:

It's the same as cmd, but only two lines.

Chcp 65001.\ a.exe

You can see the message at the terminal.

Second, modify the way the code is opened and saved in vscode

Just save the code as gb2312. You can see the current file encoding method in the lower right corner of vscode. Click utf-8 to modify and save the file to gb2312.

The above is all the content of this article "vscode debugging c language Chinese garbled solution". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Code program random code console utf-8 control method Chinese situation mode run language code character that is content article success below two Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi MariaDB Shulou Information Huawei Shulou Tech Info