banner
李大仁博客

李大仁博客

天地虽大,但有一念向善,心存良知,虽凡夫俗子,皆可为圣贤。

Linux File Batch Encoding Conversion iconv Command

Encoding conversion in Linux can be easily done using the iconv command. It supports both single file and batch processing. The iconv command can convert a file from one known character set to another known character set. Its purpose is to convert text encoding within various international encoding formats.

Shell command for processing a single file:

iconv -t utf-8 -f gb2312 source > target

# -f source encoding # -t target encoding # -l: list known encoding character sets # -o file: specify output file # -c: ignore illegal characters in output # -s: suppress warning messages, but not error messages

Shell command for batch processing:

Batch processing for directories#

find default -type d -exec mkdir -p utf/{} \;

Batch processing for files#

find default -type f -exec iconv -f gb2312 -t utf-8 -o utf/{} \;

Reference: http://blog.chinaunix.net/uid-9525959-id-2001822.html http://www.51testing.com/html/00/130600-868004.html

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.