() — MISC. REFERENCE MANUAL PAGES
NAME
iconv − code set conversion utility
SYNOPSIS
iconv -f fromcode -t tocode [-m mode] [file]
DESCRIPTION
iconv converts the encoding of characters in file from one code set to another and writes the results to standard output.
The required arguments, fromcode and tocode, identify the input and output code sets, respectively. The optional argument mode provides a further distinction between multiple code set maps for the same fromcode and tocode. If no file argument is specified on the command line, iconv reads the standard input.
iconv uses a database with four required fields (fromcode, tocode, table, file) and one optional field (mode). The order of the database fields is as named above. The database fields are separated by spaces or tabs, and the database rows are separated by newlines. The optional field mode does not have to be uniformly included or excluded from the database, that is, it may be included in some rows and not in others.
iconv matches the required arguments fromcode and tocode and the optional argument mode to the corresponding fields in the database. If the mode argument is not included in the iconv command line, iconv will match the first row found that contains the correct fromcode and tocode fields, ignoring any mode fields.
The naming conventions in the database are left entirely up to the user. However, absolute pathnames are required for the file fields not located in /usr/lib/kbd.
The following table lists the supported conversions.
| Code Set Conversions Supported | |||||
| initial | fromcode | target | tocode | modes | comment |
| code set | symbol | code set | symbol | ||
| ISO 6937 | 6937 | ISO 8859-1 | 88591 | d | Teletext |
| ISO 8859-1 | 88591 | ISO 6937 | 6937 | d | Teletext |
| ISO 646 | 646 | ISO 8859-1 | 88591 | d | US ASCII |
| ISO 646DE | 646DE | ISO 8859-1 | 88591 | d | German |
| ISO 646DK | 646DK | ISO 8859-1 | 88591 | d | Danish |
| ISO 646GB | 646GB | ISO 8859-1 | 88591 | d | English ASCII |
| ISO 646ES | 646ES | ISO 8859-1 | 88591 | d | Spanish |
| ISO 646FR | 646FR | ISO 8859-1 | 88591 | d | French |
| ISO 646IT | 646IT | ISO 8859-1 | 88591 | d | Italian |
| ISO 646NO | 646NO | ISO 8859-1 | 88591 | d | Norwegian |
| ISO 646SE | 646SE | ISO 8859-1 | 88591 | d | Swedish |
| ISO 646PT | 646PT | ISO 8859-1 | 88591 | d | Portuguese |
| ISO 646YU | 646YU | ISO 8859-2 | 88592 | d | Serbo Croatian |
| ISO 8859-1 | 88591 | ISO 646 | 646 | d b e p | 7 bit ASCII |
| ISO 8859-1 | 88591 | ISO 646DE | 646DE | d b e p | German |
| ISO 8859-1 | 88591 | ISO 646DK | 646DK | d b e p | Danish |
| ISO 8859-1 | 88591 | ISO 646GB | 646GB | d b e p | English ASCII |
| ISO 8859-1 | 88591 | ISO 646ES | 646ES | d b e p | Spanish |
| ISO 8859-1 | 88591 | ISO 646FR | 646FR | d b e p | French |
| ISO 8859-1 | 88591 | ISO 646IT | 646IT | d b e p | Italian |
| ISO 8859-1 | 88591 | ISO 646NO | 646NO | d b e p | Norwegian |
| ISO 8859-1 | 88591 | ISO 646SE | 646SE | d b e p | Swedish |
| ISO 8859-1 | 88591 | ISO 646PT | 646PT | d b e p | Portuguese |
| ISO 8859-2 | 88592 | ISO 646 | 646 | d b e | |
| ISO 8859-2 | 88592 | ISO 646YU | 646YU | d b e | Serbo Croatian |
| PC 437 | PC437 | ISO 8859-1 | 88591 | d b e p | United States |
| ISO 8859-1 | 88591 | PC 437 | PC437 | d b e p | |
| PC 850 | PC850 | ISO 8859-1 | 88591 | d b e p | Multilingual |
| ISO 8859-1 | 88591 | PC 850 | PC850 | d b e p | |
| PC 860 | PC860 | ISO 8859-1 | 88591 | d b e | Portugal |
| ISO 8859-1 | 88591 | PC 860 | PC860 | d b e p | |
| PC 863 | PC863 | ISO 8859-1 | 88591 | d b e | Canada - French |
| ISO 8859-1 | 88591 | PC 863 | PC863 | d b e p | |
| PC 865 | PC865 | ISO 8859-1 | 88591 | d b e | Norway |
| ISO 8859-1 | 88591 | PC 865 | PC865 | d b e p | |
| PC 437 | PC437 | ISO 646 | 646 | d b e | United States |
| PC 850 | PC850 | ISO 646 | 646 | d b e | Multilingual |
| PC 860 | PC860 | ISO 646 | 646 | d b e | Portugal |
| PC 863 | PC863 | ISO 646 | 646 | d b e | Canada - French |
| PC 865 | PC865 | ISO 646 | 646 | d b e | Norway |
| PC 437 | PC437 | EBCDIC | d | ||
| EBCDIC | PC 437 | PC437 | d | ||
| PC 437 | PC437 | IBM_EBCDIC | d | ||
| ISO 8859-1 | 88591 | ROMAN8 | d | HP LaserJet II | |
| ISO 8859-1 | 88591 | VT220 | d b e | ||
| VT220 | ISO 8859-1 | 88591 | d b e | ||
| ISO 8859-3 | 88593 | ISO 646 | 646 | d b e | Latin 3 |
| ISO 8859-4 | 88594 | ISO 646 | 646 | d b e | Latin 4 |
| ISO 8859-5 | 88595 | ISO 646 | 646 | d b e | Latin/Cyrillic |
| ISO 8859-7 | 88597 | ISO 646 | 646 | d b e | Latin/Greek |
| ISO 646 | 646 | ISO 8859-1 | 8859 | US ASCII | |
| ISO 646de | 646de | ISO 8859-1 | 8859 | German | |
| ISO 646da | 646da | ISO 8859-1 | 8859 | Danish | |
| ISO 646en | 646en | ISO 8859-1 | 8859 | English ASCII | |
| ISO 646es | 646es | ISO 8859-1 | 8859 | Spanish | |
| ISO 646fr | 646fr | ISO 8859-1 | 8859 | French | |
| ISO 646it | 646it | ISO 8859-1 | 8859 | Italian | |
| ISO 646sv | 646sv | ISO 8859-1 | 8859 | Swedish | |
| ISO 8859-1 | 8859 | ISO 646 | 646 | 7 bit ASCII | |
| ISO 8859-1 | 8859 | ISO 646de | 646de | German | |
| ISO 8859-1 | 8859 | ISO 646da | 646da | Danish | |
| ISO 8859-1 | 8859 | ISO 646en | 646en | English ASCII | |
| ISO 8859-1 | 8859 | ISO 646es | 646es | Spanish | |
| ISO 8859-1 | 8859 | ISO 646fr | 646fr | French | |
| ISO 8859-1 | 8859 | ISO 646it | 646it | Italian | |
| ISO 8859-1 | 8859 | ISO 646sv | 646sv | Swedish | |
ISO 646 is equivalent to U.S. 7-bit ASCII.
The optional modes (d, b, e, and p) have the following meaning:
d default Any character that cannot be represented is mapped to the "ultimate fall back character," which in the tables supplied is the underscore character ’_’.
b best fit with no expansion
Where possible, characters are mapped to the closest approximation of that character but always without expansion. That is, all the character mappings are one-to-one. This will be important, for example, when using curses-based applications where any expansion of a character representation would affect the screen management. (If such code set mappings are performed by the STREAMS module in the tty subsystem, then such mappings will be transparent and the application will have no knowledge that these mappings take place.)
e best fit with expansion
Where possible, characters of the source code set are mapped to the closest approximation of that character in the target code set. Where necessary the character in the source code set is expanded to a sequence of characters in the target code set.
p printer mode — with overstriking
If there is a non-destructive backspace, as exists on many printers, then characters that are not available can be displayed by overstriking. In this way many accented characters can be displayed.
EXAMPLES
An example of a database for iconv is shown below, with the following fields:
| fromcode | tocode | table | file | mode |
| (the above field names are not included in the database). | ||||
| 88591 | 646FR | pubtable | 88591.646FR.d | d |
| 88591 | 646FR | 88591.646FR.b | pubfile | b |
| 646 | 646DE | togerman | /mydir/togerman | |
Using the above database, the following command converts the contents of file mail1 from the ISO 8859-1 code set to ISO 646FR using the d mode and stores the results in file mail.local.
iconv -f 88591 -t 646FR -m d mail1 > mail.local
The following command will accomplish the same result as above, because the d mode conversion from 88591 to 646FR is the first row found in the database containing the correct code set conversion.
iconv -f 88591 -t 646FR mail1 > mail.local
FILES
/usr/lib/kbd/iconv_datadefault database of supported conversions
/usr/lib/kbd/∗.[tbdep]conversion tables
NOTES
The table titled "Code Set Conversions Supported" assumes that the full BOS is available. If the European Language Supplement package of the BOS is not installed, only those conversions shown in the table with a blank mode field are available.
SEE ALSO
DIAGNOSTICS
iconv returns 0 upon successful completion, 1 otherwise.