Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The solution of Chinese garbled code in vscode debugging c language

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report