Solution to cmd execution golang garbled code

Release: 2019-12-05 13:52:06
Original
3403 people have browsed it

Solution to cmd execution golang garbled code

Because the encoding of Go is UTF-8, and the active page of cmd is cp936 (GBK), it is garbled. Solution:

How to display UTF-8 characters in the DOS window

In the Chinese Windows system, if a text file is UTF-8 encoded, then in the CMD.exe command line window (so-called DOS window) does not display the contents of the file correctly. By default, the code page used in the command line window is Chinese or American, that is, the encoding is the Chinese character set or the Western character set.

If you want to display UTF-8 characters correctly, you can follow the following steps:

1. Open the CMD.exe command line window

2. Change the code page through the chcp command , the code page of UTF-8 is 65001

chcp 65001. After executing this operation, the code page will be changed to UTF-8. However, UTF-8 characters still cannot be displayed correctly in the window.

3. Modify the window properties and change the font

Right-click on the command line title bar, select "Properties"->"Font", and change the font to True Type font "Lucida Console" " and click OK to apply the properties to the current window.

At this time, you can use the type command to display the content of the UTF-8 text file:

type filename.txt
Copy after login

4. The above operations cannot completely solve the problem, because the displayed content may not be complete. . You can first minimize and then maximize the command line window, and the contents of the file will be fully displayed.

For more golang knowledge, please pay attention to the golang tutorial column.

The above is the detailed content of Solution to cmd execution golang garbled code. 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!