iconv reads input characters from a file or from standard input, converts the encoding of these characters, and writes the results on the standard output.
The conversions that can be performed with iconv are defined in conversion tables located in the directory /usr/lib/iconv.
iconv is typically used to convert characters from the ISO 8859-1 character set to an ISO 646 ASCII variant codeset for a particular language and vice versa (see Examples on "iconv code set conversion").
BS2000
You can use iconv for code conversions between ISO646 and EDF03, that is to say between ASCII 7-bit code and EBCDIC.
Syntax
iconv -f fromcode -t tocode[ file] |
iconv expects the conversion table to be in the file /usr/lib/iconv/fromcode.tocode.t. Any character that does not exist in the target codeset is converted to an underscore ’_’.
Name of the file for which codeset conversion is to be performed. file not specified: |
Error
iconv does not support the requested conversion from codeset xx to target codeset yy. |
File
/usr/lib/iconv Directory containing the standard conversion tables for codeset conversion /usr/lib/iconv/iconv_data Auxiliary file for iconv /usr/lib/iconv/*.t Conversion tables |
Locale
The following environment variables affect the execution of iconv: LANG Provide a default value for the internationalization variables that are unset or null. If LANG is unset of null, the corresponding value from the implementation-specific default locale will be used. If any of the internationalization variables contains an invalid setting, the utility will behave as if none of the variables had been defined. LC_ALL If set to a non-empty string value, override the values of all the other internationalization variables. LC_CTYPE 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 and input files), the classification of characters as upper- to lower-case, and the mapping of characters from one case to the other. LC_MESSAGES Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error. NLSPATH Determine the location of message catalogs for the processing of LC_MESSAGES. |
Example 1
List all conversion tables:
|
Example 2
Convert the file named letter and save the result in a file named letter.conv. The conversion is to be made from the German variant of the ISO 646 codeset (ASCII derivative) to the target codeset ISO 8859-1:
|
Example 3
You want to convert the contents of the file bs2000 from ASCII to EBCDIC and write the
|