Home Backend Development Golang Solution to cmd execution golang garbled code

Solution to cmd execution golang garbled code

Dec 05, 2019 pm 01:52 PM
golang Garbled characters

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!

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

Hot Article

Hot Article

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to safely read and write files using Golang? How to safely read and write files using Golang? Jun 06, 2024 pm 05:14 PM

How to safely read and write files using Golang?

How to configure connection pool for Golang database connection? How to configure connection pool for Golang database connection? Jun 06, 2024 am 11:21 AM

How to configure connection pool for Golang database connection?

Similarities and Differences between Golang and C++ Similarities and Differences between Golang and C++ Jun 05, 2024 pm 06:12 PM

Similarities and Differences between Golang and C++

How steep is the learning curve of golang framework architecture? How steep is the learning curve of golang framework architecture? Jun 05, 2024 pm 06:59 PM

How steep is the learning curve of golang framework architecture?

How to generate random elements from list in Golang? How to generate random elements from list in Golang? Jun 05, 2024 pm 04:28 PM

How to generate random elements from list in Golang?

Comparison of advantages and disadvantages of golang framework Comparison of advantages and disadvantages of golang framework Jun 05, 2024 pm 09:32 PM

Comparison of advantages and disadvantages of golang framework

What are the best practices for error handling in Golang framework? What are the best practices for error handling in Golang framework? Jun 05, 2024 pm 10:39 PM

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

golang framework document usage instructions golang framework document usage instructions Jun 05, 2024 pm 06:04 PM

golang framework document usage instructions

See all articles