1. View how files are encoded: File command
file Test_file.txttest_file.txt:ISO-8859longfile train_model.py Train_model.py:Python script, UTF-8file+
However, the file command is not reliable, and a gb2312 encoded document is judged to be ISO-8859
2. Open the file in Gedit with the specified encoding
Open Gedit, then file = + open and the lower left corner of character encoding has a drop-down list on the right, select Add or Remove ... \ = The setup interface shown, Select the desired encoding from the list on the left to add to the list on the right
Then, when you open the file, select the encoding you want:
3. transcoding: Iconv command
$ iconv-f gb2312-t utf-8 test_file.txt-file Test_file_utf8.txttest_file_utf8.txt:UTF -8 Unicode text
The use of the Iconv command is as follows:
$ iconv--Helpusage:iconv [OPTION ...] [FILE ...] Convert encoding of given files from one encoding to another. Input/Output format specification:-F,--from-code=NAME encoding of original text-T,--to-code=name encoding forOutput Information:-L,--List all known coded character sets Output control:-c omit invalid characters from output-O,--output=file outputfile-S,--Silent Suppress warnings--Verbose print Progress information-?, --Help Give this help list--usage Give A ShortUsage Message-V,--version Print program versionmandatory or optional arguments toLongoptions are also mandatory or optional forAny corresponding Shortoptions. For bugs reporting instructions, please see://bugs.launchpad.net/ubuntu/+source/glibc/+bugs>.
Reference: https://www.cnblogs.com/longwaytogo/p/6308703.html
Open Windows Chinese text garbled problem under Linux