iconv

From Wikipedia, the free encyclopedia
Jump to: navigation, search

In Unix-like operating systems, iconv is a command-line program[1] and a standardized application programming interface (API)[2] used to convert between different character encodings. "It can convert from any of these encodings to any other, through Unicode conversion."[3]

History[edit]

Initially appearing on the HP-UX operating system,[4]iconv() as well as the utility was standardized within XPG4 and is part of the Single UNIX Specification (SUS).

Implementations[edit]

All recent Linux distributions contain a free implementation of iconv utility and iconv() function as part of the GNU C Library which is the C library for current Linux systems. The library's iconv() function[5] as well as the utility[6] is licensed as LGPL, so it is linkable with closed source applications. To use the library, the GNU glibc locales need to be installed, which are provided as a separate package (usually named glibc-locale)[citation needed] normally installed by default.

GNU also provides a separate iconv implementation in its "libiconv" package. Unlike the glibc implementation, the utility in "libiconv" is licensed under GPL, so derivatives must be open in GPL too.[3] This separate implementation can be seen in non-glibc platforms that still need iconv functionalities like Cygwin[7] and GnuWin32.[8]

The uconv utility from International Components for Unicode provides an iconv-compatible command-line syntax for transcoding.

Ports[edit]

Under Microsoft Windows, the iconv library and the utility is provided by GNU's libiconv found in Cygwin[7] and GnuWin32[8] environments; there is also a "purely Win32" implementation called "win-iconv" that uses Windows' built-in routines for conversion.[9]

The iconv function is also available for many programming languages.

Usage[edit]

stdin can be converted from ISO-8859-1 to current locale and output to stdout using:[10]

iconv -f iso-8859-1

An input file infile can be converted from ISO-8859-1 to UTF-8 and output to output file outfile using:

iconv -f iso-8859-1 -t utf-8 <infile >outfile

See also[edit]

References[edit]

  1. ^ iconv (utility) OpenGroup Standards page
  2. ^ iconv() OpenGroup Standards page
  3. ^ a b gnu.org: libiconv
  4. ^ iconv(3C):Author
  5. ^ "glibc: iconv/iconv.c". Retrieved 30 November 2016. 
  6. ^ "glibc: iconv/iconv_prog.c". Retrieved 30 November 2016. 
  7. ^ a b "Cygwin Package Search: libiconv". Archived from the original on 30 November 2016. Retrieved 30 November 2016. 
  8. ^ a b GnuWin32: libiconv
  9. ^ "win32-iconv". GitHub. Retrieved 30 November 2016. 
  10. ^ IBM knowledge base: iconv examples

External links[edit]