Open Windows Chinese text garbled problem under Linux

Source: Internet
Author: User
Tags python script

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.