iconv
In Unix-like operating systems, iconv (an abbreviation of internationalization conversion)[1] is a command-line program[2] and a standardized application programming interface (API)[3] used to convert between different character encodings. "It can convert from any of these encodings to any other, through Unicode conversion."[4]
History
Initially appearing on the HP-UX operating system,[5]iconv()
as well as the utility was standardized within XPG4 and is part of the Single UNIX Specification (SUS).
Implementations
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[6] as well as the utility[7] 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) 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 software linking to it must be GPL compatible.[4] This separate implementation can be seen in non-glibc platforms that still need iconv functionalities such as Cygwin[8] and GnuWin32.[9]
The uconv utility from International Components for Unicode provides an iconv-compatible command-line syntax for transcoding.
Support
Currently, over a hundred different character encodings are supported.[4]
Ports
Under Microsoft Windows, the iconv library and the utility is provided by GNU's libiconv found in Cygwin[8] and GnuWin32[9] environments; there is also a "purely Win32" implementation called "win-iconv" that uses Windows' built-in routines for conversion.[10] The iconv function is also available for many programming languages.
Usage
stdin
can be converted from ISO-8859-1 to current locale and output to stdout
using:[11]
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
References
- ↑ "R: Convert Character Vector between Encodings". astrostatistics.psu.edu. Retrieved 21 April 2018.
- ↑ "iconv". pubs.opengroup.org. Retrieved 21 April 2018.
- ↑ "iconv". www.opengroup.org. Retrieved 21 April 2018.
- 1 2 3 "libiconv - GNU Project - Free Software Foundation (FSF)". www.gnu.org. Retrieved 21 April 2018.
- ↑ "iconv(3C)". docstore.mik.ua. Retrieved 21 April 2018.
- ↑ "glibc: iconv/iconv.c". Retrieved 30 November 2016.
- ↑ "glibc: iconv/iconv_prog.c". Retrieved 30 November 2016.
- 1 2 "Cygwin Package Search: libiconv". Archived from the original on 30 November 2016. Retrieved 30 November 2016.
- 1 2 "LibIconv for Windows". gnuwin32.sourceforge.net. Retrieved 21 April 2018.
- ↑ "win32-iconv". GitHub. Retrieved 30 November 2016.
- ↑ "IBM Knowledge Center". www-01.ibm.com. Retrieved 21 April 2018.
External links