Windows CMD window setting encoding format: UTF-8

The CMD window under Windows uses non-GBK encoding by default, and sometimes the output of running some batch files written in UTF-8 in the console is garbled.

CHCP is a command in MD DOS used to display or set the active code page number. The usage is: 
CHCP [num] 
where num specifies the code page number. This parameter is optional. If, in the default cmd window, we only enter chcp, the display will be similar to: 
active code page: 936 

Among them, 936 is the number of various coding languages.

The following are several commonly used codes: 
936 GBK (generally the default code) 
437 American English 
65001 utf-8

To set the CMD window encoding format to UTF-8:

1. Run CMD 
2. Enter chcp 65001 in the command line and press Enter, the console will switch to the new code page. 

3. Right-click on the title bar and open the properties panel. You will see the encoding of the "Current Code Page" displayed under the "Options" tab. Then select the "Font" tab, set the font to Lucia Console, and then confirm to close.

If you want to set back to the default encoding:
1. Run CMD 

2. Enter chcp 936 in the command line and press Enter, the console will switch to the new code page. 

3. At this time, the encoding of the code page has been changed to the default, but it can be closed and reopened or other encodings, you can right-click on the title bar, open the properties panel, select the "Options" tab, select "Discard old copies" and more Option, and then OK to close.

Verify that the CMD encoding format is updated

Step 1. Run the CMD window, right-click the top of the CMD window, and select Properties.

View options -> current page number:

 

Guess you like

Origin blog.csdn.net/zhouzhiwengang/article/details/113102874