Solution to the garbled output problem of cat in golang

藏色散人
Release: 2021-04-01 17:06:24
forward
2575 people have browsed it

The tutorial column of golang below will introduce to you how to solve the problem of cat output garbled characters. I hope it will be helpful to friends in need!

Solution to the garbled output problem of cat in golang

I encountered a problem today. Check the result set returned by the log file. Use the command:

 cat xxx.log | grep '2021-03-07' | grep 'abc' | grep 110
Copy after login

to find the output Chinese garbled characters, vim to check the file encoding :

vim xxx.log:set fileencoding
Copy after login

The file encoding is: cp936
Since it will be garbled, let’s be simple and crude, directly convert the file encoding, use the following command:

iconv -f cp936 -t utf-8 xxx.log  > xxx_utf.log
Copy after login

Then operate the xxx_utf.log file:

 cat xxx_utf.log | grep '2021-03-07' | grep 'abc' | grep 110
Copy after login

The output is normal.                                                                                                                

The above is the detailed content of Solution to the garbled output problem of cat in golang. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:learnku.com
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