Home  >  Article  >  Backend Development  >  Solution to the garbled output problem of cat in golang

Solution to the garbled output problem of cat in golang

藏色散人
藏色散人forward
2021-04-01 17:06:242574browse

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

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

vim xxx.log:set fileencoding

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

Then operate the xxx_utf.log file:

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

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!

Statement:
This article is reproduced at:learnku.com. If there is any infringement, please contact admin@php.cn delete