Linux bulk GDK encoded articles into UTF-8 encoded articles and "ICONV: illegal input sequence unknown XXX" error handling

Source: Internet
Author: User

Batch conversion GBK file to UTF-8 encoding method under Linux

View File Encoding

File-i filename

1. Recursive conversions (including subfolders)

Find Default-type d-exec mkdir-p utf/{} \;

Find Default-type f-exec iconv-f gbk-t UTF-8 {}-o utf/{} \;

These two lines of command convert the file under the default directory from GBK encoding to UTF-8 encoding, the directory structure is unchanged, and the transcoded file is saved in the Utf/default directory.

2. Conversion

The command format is as follows

$enca-L Current language-x target encoded file name

For example, to turn all files in the current directory into Utf-8

$enca-L zh_cn-x utf-8 *


ICONV: illegal input sequence at unknown XXX

Under the Linux command line bash, there was a problem with iconv conversion UTF-8 encoding to gb2312: iconv: Illegal input sequence at unknown XX

Adding the-C option to iconv, ignoring invalid characters, succeeded.

/*--------------------------------I am the split line--------------------------------*/

Above reference http://hi.baidu.com/maleung/blog/item/a75403ed6ea19fd8b21cb1db.html

-----------------------------------------------------------------

You can also add//ignor to the parameters as in PHP, as follows

Iconv-f gbk//ignore-t Utf8//ignore hufu.csv> hufu-utf8.csv

can also be performed normally


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.