Processing the conversion from GB2312 to UTF-8 in Linux
Source: Internet
Author: User
Article Title: Linux system to handle the conversion from GB2312 to UTF-8. Linux is a technology channel of the IT lab in China. Including desktop applications, Linux system management, kernel research, embedded systems and open-source and other basic classification UTF-8 this encoding has been the trend of the times, but there are many Chinese documents retain the old GB2312 encoding, as long as you have to deal with Windows, you have to deal with GB2312, such as the 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 GB2312 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 GB2312. At this time, we can change GB2312 to its superset GB18030, generally, the problem is solved:
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.