Converting from GB2132 to UTF-8 in Linux

Source: Internet
Author: User
Linux to process the conversion from GB2132 to UTF-8-Linux general technology-Linux technology and application information, the following is a detailed reading. Original Author: peigen

UTF-8 this encoding has been the trend of the times, but there are a lot of Chinese documents retain the old GB2132 encoding, and as long as you have to deal with Windows, it is inevitable to deal with the problem of GB2132, for example, you can process source code, text files, and letter files copied from Windows.

Most of us know the encoding conversion method, but I just forget it.

The iconv command in Linux can be used to convert character encoding. The basic command format is as follows:

Iconv-f original encoding-t destination encoding File Name> New File Name
-F indicates from, and-t indicates.

If I want to convert text.txt from GB2132 encoding to a UTF-8 and save it as a text-utf-8.txt, the command is as follows:

Iconv-f gb2312-t UTF-8 text.txt> text-utf-8.txt

However, sometimes an error is reported during conversion, probably because some characters in the original file exceed the range of GB2132. At this time, we can change GB2312 to its superset GB18030, generally, the problem is solved:

Iconv-f gb18030-t UTF-8 text.txt> text-utf-8.txt
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.