Iconv - Character Encoding Converter Tool

Convert character encodings easily with Iconv. Transform between various formats like UTF-8, ISO-8859-1, and more. Free online tool for developers.

Iconv - Character Encoding Converter

Understanding Iconv for Character Encoding Conversion

The iconv command-line utility is a powerful tool for converting character encodings between different formats. It's essential for developers and system administrators who need to handle text files that may be stored in various encodings, such as ASCII, UTF-8, ISO-8859-1, and many others. By using iconv, you can ensure that your text data is correctly interpreted and displayed across different systems and applications.

Basic Usage of Iconv

The fundamental syntax for using iconv involves specifying the source encoding, the target encoding, and the input and output files. This allows for precise control over how character data is transformed.

Example: Converting ISO-8859-1 to UTF-8

Below is a common use case where a file encoded in ISO-8859-1 needs to be converted to UTF-8. This is particularly useful when dealing with legacy systems or international character sets.

# To convert file (iconv.src) from iso-8859-1 to utf-8 and save to /tmp/iconv.out
iconv -f iso-8859-1 -t utf-8 iconv.src -o /tmp/iconv.out

Key Options and Parameters

  • -f <encoding>: Specifies the input (from) encoding.
  • -t <encoding>: Specifies the output (to) encoding.
  • -o <file>: Writes the output to the specified file. If omitted, output goes to standard output.

Further Resources