# Iconv

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/Iconv
> Markdown URL: https://mediated.wiki/source/Iconv.md
> Source: https://en.wikipedia.org/wiki/Iconv
> Source revision: 1353507385
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

{{short description|Standard UNIX utility}}
{{Use dmy dates|date=March 2017}}
{{Lowercase title}}
{{Infobox software
| name = iconv
| logo = 
| screenshot = 
| screenshot size = 
| caption = 
| author = [Hewlett-Packard](/source/Hewlett-Packard)
| developer = Various [open-source](/source/open-source_software) and [commercial](/source/commercial_software) developers
| released = 
| latest release version = 
| latest release date = 
| repo = https://git.savannah.gnu.org/git/libiconv.git
| operating system = [Unix](/source/Unix), [Unix-like](/source/Unix-like), [Microsoft Windows](/source/Microsoft_Windows), [IBM i](/source/IBM_i)
| platform = [Cross-platform](/source/Cross-platform)
| genre = [Command](/source/Command_(computing))
| license = libiconv: [LGPL](/source/LGPL)<br/>iconv: [GPL](/source/GPL)<br />win-iconv: [Public domain](/source/Public_domain)<ref>{{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](/source/GitHub) |access-date=20 December 2020 |archive-date=9 August 2022 |archive-url=https://web.archive.org/web/20220809234626/https://github.com/win-iconv/win-iconv/blob/master/readme.txt |url-status=live }}</ref>
| website = 
}}
In [Unix](/source/Unix) and [Unix-like](/source/Unix-like) operating systems, '''iconv''' (an abbreviation of [internationalization](/source/Internationalization_and_localization) conversion)<ref>{{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|archive-date=31 October 2020|archive-url=https://web.archive.org/web/20201031005810/https://astrostatistics.psu.edu/su07/R/html/base/html/iconv.html|url-status=live}}</ref> is a command-line [program](/source/computer_program)<ref>{{cite web|url=http://pubs.opengroup.org/onlinepubs/9699919799/utilities/iconv.html|title=iconv|website=pubs.opengroup.org|access-date=21 April 2018|archive-date=28 October 2020|archive-url=https://web.archive.org/web/20201028210908/https://pubs.opengroup.org/onlinepubs/9699919799/utilities/iconv.html|url-status=live}}</ref> and a standardized [application programming interface](/source/application_programming_interface) (API)<ref>{{cite web|url=http://www.opengroup.org/onlinepubs/009695399/functions/iconv.html|title=iconv|website=www.opengroup.org|access-date=21 April 2018|archive-date=8 December 2010|archive-url=https://web.archive.org/web/20101208080641/http://www.opengroup.org/onlinepubs/009695399/functions/iconv.html|url-status=live}}</ref> used to convert between different [character encoding](/source/character_encoding)s. "It can convert from any of these encodings to any other, through Unicode conversion."<ref name="gnulibiconv">{{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|archive-date=1 May 2018|archive-url=https://web.archive.org/web/20180501010216/http://www.gnu.org/software/libiconv/|url-status=live}}</ref>

== History ==
Initially appearing on the [HP-UX](/source/HP-UX) operating system,<ref>{{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|archive-date=7 December 2019|archive-url=https://web.archive.org/web/20191207091213/https://docstore.mik.ua/manuals/hp-ux/en/B2355-60130/iconv.3C.html|url-status=live}}</ref><code>iconv()</code> as well as the utility was standardized within [XPG4](/source/X%2FOpen_Portability_Guide) and is part of the [Single UNIX Specification](/source/Single_UNIX_Specification) (SUS).

== Implementations ==
Most [Linux distribution](/source/Linux_distribution)s provide an implementation, either from the [GNU](/source/GNU) Standard C Library (included since version 2.1, February 1999), or the more traditional GNU <code>libiconv</code>, for systems based on other Standard C Libraries.

The <code>iconv</code> function<ref>{{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|archive-date=19 January 2025|archive-url=https://web.archive.org/web/20250119185121/https://sourceware.org/git/?p=glibc.git;a=blob;f=iconv/iconv.c|url-status=dead}}</ref> on both is licensed as [LGPL](/source/LGPL), so it is linkable with closed source applications.

Unlike the libraries, the <code>iconv</code> utility is licensed under [GPL](/source/GPL) in both implementations.<ref>{{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|archive-date=19 January 2025|archive-url=https://web.archive.org/web/20250119184705/https://sourceware.org/git/?p=glibc.git;a=blob;f=iconv/iconv_prog.c|url-status=dead}}</ref>
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](/source/uconv) utility from [International Components for Unicode](/source/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](/source/musl) C library implements the <code>iconv</code> function with support for all encodings specified by the [WHATWG](/source/WHATWG) Encoding Standard.

=== Support ===
Currently, over a hundred different character encodings are supported in the GNU variant.<ref name="gnulibiconv"/>

=== Ports ===
Under [Microsoft Windows](/source/Microsoft_Windows), the iconv library and the utility is provided by GNU's libiconv found in [Cygwin](/source/Cygwin)<ref name="cygwin-libiconv-search">{{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 }}</ref><!-- Search result pages are perishable. --> and [GnuWin32](/source/GnuWin32)<ref name="gnuwin32-libiconv">{{cite web|url=https://gnuwin32.sourceforge.net/packages/libiconv.htm|title=LibIconv for Windows|website=gnuwin32.sourceforge.net|access-date=21 April 2018}}</ref> environments; there is also a "purely Win32" implementation called "win-iconv" that uses Windows' built-in routines for conversion.<ref name="win-iconv">{{cite web|title=win32-iconv|url=https://github.com/win-iconv/win-iconv|website=GitHub|access-date=30 November 2016|archive-date=9 January 2017|archive-url=https://web.archive.org/web/20170109053505/https://github.com/win-iconv/win-iconv|url-status=live}}</ref> The iconv function is also available for many programming languages.

The {{Mono|iconv}} command has also been ported to the [IBM i](/source/IBM_i) operating system.<ref>{{cite web |title=IBM System i Version 7.2 Programming Qshell |language=en |author=IBM |website=[IBM](/source/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 |archive-date=18 September 2020 |archive-url=https://web.archive.org/web/20200918130823/https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_74/rzahz/rzahzpdf.pdf?view=kc |url-status=live }}</ref>

== Usage ==
<code>[stdin](/source/stdin)</code> can be converted from [ISO-8859-1](/source/ISO%2FIEC_8859-1) to current locale and output to <code>[stdout](/source/stdout)</code> using:<ref>{{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|archive-date=5 March 2016|archive-url=https://web.archive.org/web/20160305103732/http://www-01.ibm.com/support/knowledgecenter/ssw_aix_53/com.ibm.aix.cmds/doc/aixcmds3/iconv.htm|url-status=live}}</ref>

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

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

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

== See also ==
* [uconv](/source/uconv)
* [luit](/source/luit)
* [List of Unix commands](/source/List_of_Unix_commands)
* [International Components for Unicode](/source/International_Components_for_Unicode)

== 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}}
{{Hewlett-Packard software}}

Category:HP software
Category:Unix text processing utilities
Category:Unix SUS2008 utilities
Category:IBM i Qshell commands
Category:C POSIX library

---
Adapted from the Wikipedia article [Iconv](https://en.wikipedia.org/wiki/Iconv) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/Iconv?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
