Home > Development Tools > VSCode > body text

vscode console garbled Chinese characters

王林
Release: 2019-11-06 14:22:19
Original
10928 people have browsed it

vscode console garbled Chinese characters

First of all, the C language running program is called cmd.exe, and the default encoding of Windows cmd is 936, which is gb2312.

Run->cmd-> Right-click on the head of the white window-> Properties to view it. UTF-8 is mainly used now, so the C program encoded with UTF-8 appears garbled. .

1. Modify the character encoding in cmd or vscode console

chcp You can view the current console character encoding;

You can use chcp 65001 to modify the encoding. The following message will be displayed to indicate that the modification is successful, but it is only useful when it is currently open. The next time you open it, it will become gbk again. This method can correct the garbled code and see the effect when the code is already utf-8.

1. cmd console:

vscode console garbled Chinese characters

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 c
chcp 65001
a.exe
Copy after login

The program can output Chinese when the character encoding is utf-8.

2. vs code console

is the same as cmd, but with only 2 lines

chcp 65001
.\a.exe
Copy after login

, you can see the message in the terminal.

2. Modify the opening and saving method of the code in vs code

Save the code directly as gb2312. You can see the current file encoding method in the lower right corner of vs code. Click utf-8 to change the open and save method to gb2312.

vscode console garbled Chinese characters

vscode console garbled Chinese characters

Recommended tutorial: vscode tutorial

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template