Linux Command

iconv

Convert file encoding

Supplementary instructions

iconv command is used to convert the encoding of files. For example, it can convert UTF8 encoding to GB18030 encoding, and vice versa. A similar tool native2ascii is also provided in the JDK. The iconv development library under Linux includes iconv_open, iconv_close, iconv and other C functions, which can be used to easily convert character encodings in C/C++ programs. This is very useful in programs that capture web pages, and the iconv command is useful in debugging this Useful for class programs.

grammar

iconv -f encoding [-t encoding] [inputfile]...

Options

-f encoding: Convert characters from encoding encoding.
-t encoding: Convert characters to encoding.
-l: List the known set of encoded characters
-o file: Specify the output file
-c: Ignore illegal characters in the output
-s: Suppress warning messages, but not error messages
--verbose: display progress information
The legal characters that can be specified by -f and -t are listed in the command with the -l option.

Example

List currently supported character encodings:

iconv -l

Transcode the file file1 and output the converted file to fil2:

iconv file1 -f EUC-JP-MS -t UTF-8 -o file2

Here, without -o, the output will be sent to standard output.

Keep reading

You may need these next

Related picks, plus your reading history and saved articles.