Iconv
{{short description|Standard UNIX utility}}
{{Use dmy dates|date=March 2017}}
{{Lowercase|title=iconv}}
{{Infobox software
| name = iconv
| logo =
| screenshot =
| screenshot size =
| caption =
| author = Hewlett-Packard
| developer = Various open-source and commercial developers
| released =
| latest release version =
| latest release date =
| repo = https://git.savannah.gnu.org/git/libiconv.git
| operating system = Unix, Unix-like, Microsoft Windows, IBM i
| platform = Cross-platform
| genre = Command
| license = libiconv: LGPL
iconv: GPL
win-iconv: Public domain{{cite web |url=https://github.com/win-iconv/win-iconv/blob/master/readme.txt |title = win-iconv/readme.txt at master · win-iconv/win-iconv · GitHub| website=GitHub }}
| website =
}}
In Unix and Unix-like operating systems, iconv (an abbreviation of internationalization conversion){{cite web|url=http://astrostatistics.psu.edu/su07/R/html/base/html/iconv.html|title=R: Convert Character Vector between Encodings|website=astrostatistics.psu.edu|access-date=21 April 2018}} is a command-line program{{cite web|url=http://pubs.opengroup.org/onlinepubs/9699919799/utilities/iconv.html|title=iconv|website=pubs.opengroup.org|access-date=21 April 2018}} and a standardized application programming interface (API){{cite web|url=http://www.opengroup.org/onlinepubs/009695399/functions/iconv.html|title=iconv|website=www.opengroup.org|access-date=21 April 2018}} used to convert between different character encodings. "It can convert from any of these encodings to any other, through Unicode conversion."{{cite web|url=https://www.gnu.org/software/libiconv/|title=libiconv - GNU Project - Free Software Foundation (FSF)|website=www.gnu.org|access-date=21 April 2018}}
History
Initially appearing on the HP-UX operating system,{{cite web|url=http://docstore.mik.ua/manuals/hp-ux/en/B2355-60130/iconv.3C.html|title=iconv(3C)|website=docstore.mik.ua|access-date=21 April 2018}}iconv()
as well as the utility was standardized within XPG4 and is part of the Single UNIX Specification (SUS).
Implementations
Most Linux distributions provide an implementation, either from the GNU Standard C Library (included since version 2.1, February 1999), or the more traditional GNU libiconv
, for systems based on other Standard C Libraries.
The iconv
function{{cite web|title=glibc: iconv/iconv.c|url=https://sourceware.org/git/?p=glibc.git;a=blob;f=iconv/iconv.c|access-date=30 November 2016}}{{Dead link|date=January 2020 |bot=InternetArchiveBot |fix-attempted=yes }} on both is licensed as LGPL, so it is linkable with closed source applications.
Unlike the libraries, the iconv
utility is licensed under GPL in both implementations.{{cite web|title=glibc: iconv/iconv_prog.c|url=https://sourceware.org/git/?p=glibc.git;a=blob;f=iconv/iconv_prog.c|access-date=30 November 2016}}{{Dead link|date=January 2020 |bot=InternetArchiveBot |fix-attempted=yes }}
The GNU libiconv implementation is portable, and can be used on various UNIX-like and non-UNIX systems. Version 0.3 dates from December 1999.
The uconv utility from International Components for Unicode provides an iconv-compatible command-line syntax for transcoding.
Most BSD systems use NetBSD's implementation, which first appeared in December 2004.
The musl C library implements the iconv
function with support for all encodings specified by the WHATWG Encoding Standard.
= Support =
= Ports =
Under Microsoft Windows, the iconv library and the utility is provided by GNU's libiconv found in Cygwin{{cite web|title=Cygwin Package Search: libiconv |url=https://cygwin.com/cgi-bin2/package-grep.cgi?grep=libiconv |access-date=30 November 2016 |archive-url=https://archive.today/20161130001530/https://cygwin.com/cgi-bin2/package-grep.cgi?grep=libiconv |archive-date=30 November 2016 |url-status=dead |df=dmy-all }} and GnuWin32{{cite web|url=http://gnuwin32.sourceforge.net/packages/libiconv.htm|title=LibIconv for Windows|website=gnuwin32.sourceforge.net|access-date=21 April 2018}} environments; there is also a "purely Win32" implementation called "win-iconv" that uses Windows' built-in routines for conversion.{{cite web|title=win32-iconv|url=https://github.com/win-iconv/win-iconv|website=GitHub|access-date=30 November 2016}} The iconv function is also available for many programming languages.
The {{Mono|iconv}} command has also been ported to the IBM i operating system.{{cite web |title=IBM System i Version 7.2 Programming Qshell |language=en |author=IBM |website=IBM |author-link=IBM |url=https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_74/rzahz/rzahzpdf.pdf?view=kc |access-date=2020-09-05 }}
Usage
stdin
can be converted from ISO-8859-1 to current locale and output to stdout
using:{{cite web|url=http://www-01.ibm.com/support/knowledgecenter/ssw_aix_53/com.ibm.aix.cmds/doc/aixcmds3/iconv.htm|title=IBM Knowledge Center|website=www-01.ibm.com|access-date=21 April 2018}}
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
See also
References
{{Reflist}}
External links
{{Wikibooks|Guide to Unix|Commands}}
- [http://www.opengroup.org/onlinepubs/009695399/functions/iconv.html iconv() OpenGroup Standards page]
- [https://www.gnu.org/software/libiconv/ GNU libiconv], [https://git.savannah.gnu.org/gitweb/?p=libiconv.git code]
- [https://code.google.com/p/win-iconv/downloads/list win_iconv]
{{Unix commands}}
Category:Unix text processing utilities
Category:Unix SUS2008 utilities
Category:IBM i Qshell commands
{{Unix-stub}}