In
Unix
Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, an ...
and
Unix-like
A Unix-like (sometimes referred to as UN*X or *nix) operating system is one that behaves in a manner similar to a Unix system, although not necessarily conforming to or being certified to any version of the Single UNIX Specification. A Unix-li ...
operating systems, iconv (an abbreviation of
internationalization
In economics, internationalization or internationalisation is the process of increasing involvement of enterprises in international markets, although there is no agreed definition of internationalization. Internationalization is a crucial strateg ...
conversion) is a command-line
program and a standardized
application programming interface (API) used to convert between different
character encoding
Character encoding is the process of assigning numbers to Graphics, graphical character (computing), characters, especially the written characters of Language, human language, allowing them to be Data storage, stored, Data communication, transmi ...
s. "It can convert from any of these encodings to any other, through Unicode conversion."
History
Initially appearing on the
HP-UX operating system,
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
GNU () is an extensive collection of free software (383 packages as of January 2022), which can be used as an operating system or can be used in parts with other operating systems. The use of the completed GNU tools led to the family of operat ...
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 on both is licensed as
LGPL, so it is linkable with closed source applications.
Unlike the libraries, the
iconv
utility is licensed under
GPL
The GNU General Public License (GNU GPL or simply GPL) is a series of widely used free software licenses that guarantee end users the four freedoms to run, study, share, and modify the software. The license was the first copyleft for general u ...
in both implementations.
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
In computing, uconv is a command-line tool that is bundled with International Components for Unicode that converts text files between different character encodings. It is very similar to the ''iconv'' command that is part of the Single UNIX Specifi ...
utility from
International Components for Unicode
International Components for Unicode (ICU) is an open-source project of mature C/ C++ and Java libraries for Unicode support, software internationalization, and software globalization. ICU is widely portable to many operating systems and environ ...
provides an iconv-compatible command-line syntax for transcoding.
Most BSD systems use NetBSD's implementation, first appeared in December 2004.
Support
Currently, over a hundred different character encodings are supported.
Ports
Under
Microsoft Windows, the iconv library and the utility is provided by GNU's libiconv found in
Cygwin and
GnuWin32
The G''nu''W''in''32 project provides native ports in the form of executable computer programs, patches, and source code for various GNU and open source tools and software, much of it modified to run on the 32-bit Windows platform. The ports in ...
environments; there is also a "purely Win32" implementation called "win-iconv" that uses Windows' built-in routines for conversion.
The iconv function is also available for many programming languages.
The command has also been ported to the
IBM i operating system.
Usage
stdin
In computer programming, standard streams are interconnected input and output communication channels between a computer program and its environment when it begins execution. The three input/output (I/O) connections are called standard input (stdin ...
can be converted from
ISO-8859-1 to current locale and output to
stdout
In computer programming, standard streams are interconnected input and output communication channels between a computer program and its environment when it begins execution. The three input/output (I/O) connections are called standard input (stdin ...
using:
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 -o
See also
*
uconv
In computing, uconv is a command-line tool that is bundled with International Components for Unicode that converts text files between different character encodings. It is very similar to the ''iconv'' command that is part of the Single UNIX Specifi ...
*
luit
*
List of Unix commands
This is a list of Unix commands as specified by IEEE Std 1003.1-2008, which is part of the Single UNIX Specification (SUS). These commands can be found on Unix operating systems and most Unix-like operating systems.
List
See also
* List of G ...
*
International Components for Unicode
International Components for Unicode (ICU) is an open-source project of mature C/ C++ and Java libraries for Unicode support, software internationalization, and software globalization. ICU is widely portable to many operating systems and environ ...
References
External links
iconv() OpenGroup Standards pageGNU libiconvwin_iconv
HP software
Unix text processing utilities
Unix SUS2008 utilities
IBM i Qshell commands
C POSIX library
{{Unix-stub