International Language Environments Guide for Oracle® Solaris 11.2

Exit Print View

Updated: July 2014
 
 

iconv Utility

The iconv(1) command-line utility converts characters or sequences of characters from one code set to another. It supports a wide range of code sets. Because code set names often differ among platforms, many of the code sets are supported under multiple names thanks to an aliasing mechanism in iconv. Run the following command to obtain the list of code sets currently available in a system:

$ /usr/bin/iconv -l

Because multiple packages have iconv modules, you can extend the default list by installing additional packages. The default installation includes the system/library/iconv/utf-8 package, which covers the basic set of iconv modules for conversions among UTF-8 and other Unicode code sets and selected other code sets. Other packages are available in the System/Internationalization category in the Package Manager, or by using the system/library/iconv/* name pattern for installation with the pkg (1) command.

The iconv —f option defines the source code set and the -t option defines the target code set. You can use iconv to convert a file, or standard input, to standard output as follows:

$ /usr/bin/iconv -f eucJP -t UTF-8 file.txt

This example would convert file.txt filename from the eucJP code set (Extended UNIX Code Packed Format for Japanese) and write the result in UTF-8 to standard output.

In Oracle Solaris 11, iconv has been extended to include flags that modify the behavior of the conversion in these special situations:

  • Illegal character – The input character is not valid in the declared source code set

  • Non-identical character – There is no matching character in the target code set

Flags like //ILLEGAL_DISCARD, //NON_IDENTICAL_DISCARD, //IGNORE and //TRANSLIT can also be used at the command line. For more information, see the iconv_open(3C) man page.


Note - Some of the iconv modules in Oracle Solaris might implement only a subset of the flags described in the iconv_open(3C) man page.

For more information on iconv, see the iconv(1), iconv(3C), iconv_open(3C), and related man pages.