iconv - codeset conversion
iconv -f fromcode -t tocode [file...]
The iconv utility converts the encoding of characters in file from one codeset to another and writes the results to standard output.
Character encodings in either codeset may include single-byte values (for example, for the ISO 8859-1:1987 standard characters) or multi-byte values (for example, for certain characters in the ISO 6937:1983 standard). The results of specifying invalid characters in the input stream (either those that are not valid members of the fromcode or those that have no corresponding value in tocode) are specified in the system documentation.
The following options are supported:
- -f fromcode
Identify the codeset of the input file. Valid values for fromcode are specified in the system documentation.
- -t tocode
Identify the codeset to be used for the output file. Valid values for tocode are specified in the system documentation.
The following operands are supported:
- A pathname of the input file to be translated. If file is omitted, the standard input is used.
The standard input is used only if the file operand is omitted.
The input file is a text file.
The following environment variables affect the execution of iconv:
- Provide a default value for the internationalisation variables that are unset or null. If LANG is unset or null, the corresponding value from the implementation-dependent default locale will be used. If any of the internationalisation variables contains an invalid setting, the utility will behave as if none of the variables had been defined.
- If set to a non-empty string value, override the values of all the other internationalisation variables.
- Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments). During translation of the file, this variable is superseded by the use of the fromcode option-argument.
- Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.
- Determine the location of message catalogues for the processing of LC_MESSAGES .
The standard output is a text file containing the translated data.
Used only for diagnostic messages.
The following exit values are returned:
- Successful completion.
- An error occurred.
The following example converts the contents of file mail.x400 from the ISO 6937:1983 standard codeset to the ISO 8859-1:1987 standard codeset, and stores the results in file mail.local:
iconv -f ISO6937 -t ISO8859 mail.x400 > mail.local
gencat, iconv(), <iconv.h>.