Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

iconv - code set conversion

&pagelevel(4)&pagelevel

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]

-f fromcode
-t tocode

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 ’_’.

file

Name of the file for which codeset conversion is to be performed.

file not specified:
iconv reads from standard input.

Error

Not supported xx to yy

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:

$ ls /usr/lib/iconv

646.edf03.t   646es.8859.t  8859.646.t    8859.646es.t  8859.edf04.t

646da.8859.t  646fr.8859.t  8859.646da.t  8859.646fr.t  edf03.646.t

646de.8859.t  646it.8859.t  8859.646de.t  8859.646it.t  edf04.8859.t
646en.8859.t  646sv.8859.t  8859.646en.t  8859.646sv.t  iconv_data

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:

$ iconv -f 646de -t 8859 letter > letter.conv

Example 3

You want to convert the contents of the file bs2000 from ASCII to EBCDIC and write the
result to the file bs2000.conv:

$ iconv -f 646 -t edf03 bs2000 > bs2000.conv