Jump to content

Iconv

From Alfawiki
iconv
Company typeSoftware utility and API
IndustryComputing / Software
ProductsCharacter encoding conversion tool and API

In Unix and Unix-like environments, iconv—an abbreviation for internationalization conversion—is both a command-line tool and a standardized application programming interface (API) designed to facilitate the transformation between various character encoding formats. This utility allows encoding conversions by way of Unicode, supporting transitions from any compatible encoding to another.

History

The iconv() function and its associated utility were initially created for the HP-UX platform. They were later standardized within the XPG4 specifications and are incorporated into the Single UNIX Specification (SUS).

Implementations

Within most Linux distributions, iconv is implemented through the GNU Standard C Library (glibc) starting with version 2.1 (released in 1999), or alternatively by using GNU libiconv when other Standard C Libraries are employed. The iconv API is distributed under the LGPL license, permitting integration with proprietary software, whereas the command-line tool itself is governed by the GPL license.

GNU libiconv offers portability across both UNIX-like and non-UNIX systems, with its first release dating back to December 1999. The International Components for Unicode provide the uconv utility, which presents an iconv-compatible transcoding interface. BSD operating systems generally adopt NetBSD’s implementation, introduced in December 2004. Furthermore, the musl C library supports every encoding specified by the WHATWG Encoding Standard.

Support

The GNU version accommodates conversion among more than one hundred character encodings.

Ports

On the Microsoft Windows platform, iconv’s library and utility are available through GNU's libiconv within environments such as Cygwin and GnuWin32. Additionally, a native Win32 variant called "win-iconv" utilizes Windows’ internal conversion mechanisms. The iconv function is accessible across numerous programming languages as well.

This command has also been adapted for use on the IBM i operating system.

Usage

To convert data from ISO-8859-1 encoding to the current locale via stdin and output it to stdout, use:

<syntaxhighlight lang="bash"> iconv -f iso-8859-1 </syntaxhighlight>

To convert an input file named infile from ISO-8859-1 to UTF-8 and save the result in outfile, execute:

<syntaxhighlight lang="bash"> iconv -f iso-8859-1 -t utf-8 <infile> -o <outfile> </syntaxhighlight>

See also

External links