LinuxCommandLibrary

conv

Convert character encodings of files

SYNOPSIS

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

PARAMETERS

-f from-encoding, --from-code from-encoding
    Specify the input encoding

-t to-encoding, --to-code to-encoding
    Specify the output encoding

-l, --list
    List all known encoded names

-c
    Omit invalid characters from output

--unicode-subst formatstring
    Specify Unicode substitution format

-o file, --output-file file
    Specify output file

-s, --silent
    Suppress warnings

-v, --verbose
    Enable verbose mode

--help
    Display help

--version
    Display version info

DESCRIPTION

The iconv command is a standard Linux utility used to convert the character encoding of text files or streams. It supports a wide range of encodings such as UTF-8, ASCII, ISO-8859-1, and many others.

Common use cases include converting legacy files to modern UTF-8 for compatibility, handling international text data, or preparing files for specific applications. Input can come from files, stdin, or piped data, with output directed to files or stdout.

iconv performs on-the-fly conversion and can handle errors gracefully with options to escape invalid characters or stop on failure. It is part of the GNU libc and available on most Unix-like systems. For batch processing, it integrates well with scripts and tools like find or sed.

CAVEATS

Not all encodings are supported on every system; check with iconv -l. May consume significant memory for large files. Invalid sequences can cause incomplete conversions unless handled with -c.

ENCODING LIST

Use iconv -l to view supported encodings, grouped by aliases.

EXAMPLE USAGE

iconv -f ISO-8859-1 -t UTF-8 input.txt > output.txt
Converts ISO-8859-1 file to UTF-8.

HISTORY

Part of GNU libiconv since 1990s, evolved with glibc. Widely used for internationalization support in Unix/Linux.

SEE ALSO

recode(1), enca(1)

Copied to clipboard