Solution to cmd execution golang garbled code
Dec 05, 2019 pm 01:52 PMBecause 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
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!

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to safely read and write files using Golang?

How to configure connection pool for Golang database connection?

Similarities and Differences between Golang and C++

How steep is the learning curve of golang framework architecture?

How to generate random elements from list in Golang?

Comparison of advantages and disadvantages of golang framework

What are the best practices for error handling in Golang framework?

golang framework document usage instructions
