306 lines
7.1 KiB
HTML
306 lines
7.1 KiB
HTML
|
||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||
<HTML><HEAD><TITLE>Man page of ICONV</TITLE>
|
||
</HEAD><BODY>
|
||
<H1>ICONV</H1>
|
||
Section: Linux User Manual (1)<BR>Updated: 2019-03-06<BR><A HREF="#index">Index</A>
|
||
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
||
|
||
<A NAME="lbAB"> </A>
|
||
<H2>NAME</H2>
|
||
|
||
iconv - convert text from one character encoding to another
|
||
<A NAME="lbAC"> </A>
|
||
<H2>SYNOPSIS</H2>
|
||
|
||
<B>iconv</B>
|
||
|
||
[<I>options</I>]
|
||
|
||
[-f <I>from-encoding</I>]
|
||
|
||
[-t <I>to-encoding</I>]
|
||
|
||
[<I>inputfile</I>]...
|
||
|
||
<A NAME="lbAD"> </A>
|
||
<H2>DESCRIPTION</H2>
|
||
|
||
The
|
||
<B>iconv</B>
|
||
|
||
program reads in text in one encoding and outputs the text in another
|
||
encoding.
|
||
If no input files are given, or if it is given as a dash (-),
|
||
<B>iconv</B>
|
||
|
||
reads from standard input.
|
||
If no output file is given,
|
||
<B>iconv</B>
|
||
|
||
writes to standard output.
|
||
<P>
|
||
|
||
If no
|
||
<I>from-encoding</I>
|
||
|
||
is given, the default is derived
|
||
from the current locale's character encoding.
|
||
If no
|
||
<I>to-encoding</I>
|
||
|
||
is given, the default is derived
|
||
from the current locale's character
|
||
encoding.
|
||
<A NAME="lbAE"> </A>
|
||
<H2>OPTIONS</H2>
|
||
|
||
<DL COMPACT>
|
||
<DT id="1"><B>-f</B><I> from-encoding</I><B></B>, --from-code=<I>from-encoding</I>
|
||
|
||
<DD>
|
||
Use
|
||
<I>from-encoding</I>
|
||
|
||
for input characters.
|
||
<DT id="2"><B>-t</B><I> to-encoding</I><B></B>, --to-code=<I>to-encoding</I>
|
||
|
||
<DD>
|
||
Use
|
||
<I>to-encoding</I>
|
||
|
||
for output characters.
|
||
<DT id="3"><DD>
|
||
If the string
|
||
<B>//IGNORE</B>
|
||
|
||
is appended to
|
||
<I>to-encoding</I>,
|
||
|
||
characters that cannot be converted are discarded and an error is
|
||
printed after conversion.
|
||
<DT id="4"><DD>
|
||
If the string
|
||
<B>//TRANSLIT</B>
|
||
|
||
is appended to
|
||
<I>to-encoding</I>,
|
||
|
||
characters being converted are transliterated when needed and possible.
|
||
This means that when a character cannot be represented in the target
|
||
character set, it can be approximated through one or several similar
|
||
looking characters.
|
||
Characters that are outside of the target character set and cannot be
|
||
transliterated are replaced with a question mark (?) in the output.
|
||
<DT id="5"><B>-l</B>, <B>--list</B>
|
||
|
||
<DD>
|
||
List all known character set encodings.
|
||
<DT id="6"><B>-c</B>
|
||
|
||
<DD>
|
||
Silently discard characters that cannot be converted instead of
|
||
terminating when encountering such characters.
|
||
<DT id="7"><B>-o</B><I> outputfile</I><B></B>, --output=<I>outputfile</I>
|
||
|
||
<DD>
|
||
Use
|
||
<I>outputfile</I>
|
||
|
||
for output.
|
||
<DT id="8"><B>-s</B>, <B>--silent</B>
|
||
|
||
<DD>
|
||
This option is ignored; it is provided only for compatibility.
|
||
<DT id="9"><B>--verbose</B>
|
||
|
||
<DD>
|
||
Print progress information on standard error when processing
|
||
multiple files.
|
||
<DT id="10"><B>-?</B>, <B>--help</B>
|
||
|
||
<DD>
|
||
Print a usage summary and exit.
|
||
<DT id="11"><B>--usage</B>
|
||
|
||
<DD>
|
||
Print a short usage summary and exit.
|
||
<DT id="12"><B>-V</B>, <B>--version</B>
|
||
|
||
<DD>
|
||
Print the version number, license, and disclaimer of warranty for
|
||
<B>iconv</B>.
|
||
|
||
</DL>
|
||
<A NAME="lbAF"> </A>
|
||
<H2>EXIT STATUS</H2>
|
||
|
||
Zero on success, nonzero on errors.
|
||
<A NAME="lbAG"> </A>
|
||
<H2>ENVIRONMENT</H2>
|
||
|
||
Internally, the
|
||
<B>iconv</B>
|
||
|
||
program uses the
|
||
<B><A HREF="/cgi-bin/man/man2html?3+iconv">iconv</A></B>(3)
|
||
|
||
function which in turn uses
|
||
<I>gconv</I>
|
||
|
||
modules (dynamically loaded shared libraries)
|
||
to convert to and from a character set.
|
||
Before calling
|
||
<B><A HREF="/cgi-bin/man/man2html?3+iconv">iconv</A></B>(3),
|
||
|
||
the
|
||
<B>iconv</B>
|
||
|
||
program must first allocate a conversion descriptor using
|
||
<B><A HREF="/cgi-bin/man/man2html?3+iconv_open">iconv_open</A></B>(3).
|
||
|
||
The operation of the latter function is influenced by the setting of the
|
||
<B>GCONV_PATH</B>
|
||
|
||
environment variable:
|
||
<DL COMPACT>
|
||
<DT id="13">*<DD>
|
||
If
|
||
<B>GCONV_PATH</B>
|
||
|
||
is not set,
|
||
<B><A HREF="/cgi-bin/man/man2html?3+iconv_open">iconv_open</A></B>(3)
|
||
|
||
loads the system gconv module configuration cache file created by
|
||
<B><A HREF="/cgi-bin/man/man2html?8+iconvconfig">iconvconfig</A></B>(8)
|
||
|
||
and then, based on the configuration,
|
||
loads the gconv modules needed to perform the conversion.
|
||
If the system gconv module configuration cache file is not available
|
||
then the system gconv module configuration file is used.
|
||
<DT id="14">*<DD>
|
||
If
|
||
<B>GCONV_PATH</B>
|
||
|
||
is defined (as a colon-separated list of pathnames),
|
||
the system gconv module configuration cache is not used.
|
||
Instead,
|
||
<B><A HREF="/cgi-bin/man/man2html?3+iconv_open">iconv_open</A></B>(3)
|
||
|
||
first tries to load the configuration files by searching the directories in
|
||
<B>GCONV_PATH</B>
|
||
|
||
in order,
|
||
followed by the system default gconv module configuration file.
|
||
If a directory does not contain a gconv module configuration file,
|
||
any gconv modules that it may contain are ignored.
|
||
If a directory contains a gconv module configuration file
|
||
and it is determined that a module needed for this conversion is
|
||
available in the directory,
|
||
then the needed module is loaded from that directory,
|
||
the order being such that the first suitable module found in
|
||
<B>GCONV_PATH</B>
|
||
|
||
is used.
|
||
This allows users to use custom modules and even replace system-provided
|
||
modules by providing such modules in
|
||
<B>GCONV_PATH</B>
|
||
|
||
directories.
|
||
</DL>
|
||
<A NAME="lbAH"> </A>
|
||
<H2>FILES</H2>
|
||
|
||
<DL COMPACT>
|
||
<DT id="15"><I>/usr/lib/gconv</I>
|
||
|
||
<DD>
|
||
Usual default gconv module path.
|
||
<DT id="16"><I>/usr/lib/gconv/gconv-modules</I>
|
||
|
||
<DD>
|
||
Usual system default gconv module configuration file.
|
||
<DT id="17"><I>/usr/lib/gconv/gconv-modules.cache</I>
|
||
|
||
<DD>
|
||
Usual system gconv module configuration cache.
|
||
</DL>
|
||
<A NAME="lbAI"> </A>
|
||
<H2>CONFORMING TO</H2>
|
||
|
||
POSIX.1-2001.
|
||
<A NAME="lbAJ"> </A>
|
||
<H2>EXAMPLE</H2>
|
||
|
||
Convert text from the ISO 8859-15 character encoding to UTF-8:
|
||
<P>
|
||
|
||
|
||
|
||
$ <B>iconv -f ISO-8859-15 -t UTF-8 < input.txt > output.txt</B>
|
||
|
||
|
||
<P>
|
||
|
||
The next example converts from UTF-8 to ASCII, transliterating when
|
||
possible:
|
||
<P>
|
||
|
||
|
||
|
||
$ <B>echo abc ß α € àḃç | iconv -f UTF-8 -t ASCII//TRANSLIT</B>
|
||
abc ss ? EUR abc
|
||
|
||
|
||
<A NAME="lbAK"> </A>
|
||
<H2>SEE ALSO</H2>
|
||
|
||
<B><A HREF="/cgi-bin/man/man2html?1+locale">locale</A></B>(1),
|
||
|
||
<B><A HREF="/cgi-bin/man/man2html?1+uconv">uconv</A></B>(1),
|
||
|
||
<B><A HREF="/cgi-bin/man/man2html?3+iconv">iconv</A></B>(3),
|
||
|
||
<B><A HREF="/cgi-bin/man/man2html?3+nl_langinfo">nl_langinfo</A></B>(3),
|
||
|
||
<B><A HREF="/cgi-bin/man/man2html?7+charsets">charsets</A></B>(7),
|
||
|
||
<B><A HREF="/cgi-bin/man/man2html?8+iconvconfig">iconvconfig</A></B>(8)
|
||
|
||
<A NAME="lbAL"> </A>
|
||
<H2>COLOPHON</H2>
|
||
|
||
This page is part of release 5.05 of the Linux
|
||
<I>man-pages</I>
|
||
|
||
project.
|
||
A description of the project,
|
||
information about reporting bugs,
|
||
and the latest version of this page,
|
||
can be found at
|
||
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
|
||
<P>
|
||
|
||
<HR>
|
||
<A NAME="index"> </A><H2>Index</H2>
|
||
<DL>
|
||
<DT id="18"><A HREF="#lbAB">NAME</A><DD>
|
||
<DT id="19"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
||
<DT id="20"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
||
<DT id="21"><A HREF="#lbAE">OPTIONS</A><DD>
|
||
<DT id="22"><A HREF="#lbAF">EXIT STATUS</A><DD>
|
||
<DT id="23"><A HREF="#lbAG">ENVIRONMENT</A><DD>
|
||
<DT id="24"><A HREF="#lbAH">FILES</A><DD>
|
||
<DT id="25"><A HREF="#lbAI">CONFORMING TO</A><DD>
|
||
<DT id="26"><A HREF="#lbAJ">EXAMPLE</A><DD>
|
||
<DT id="27"><A HREF="#lbAK">SEE ALSO</A><DD>
|
||
<DT id="28"><A HREF="#lbAL">COLOPHON</A><DD>
|
||
</DL>
|
||
<HR>
|
||
This document was created by
|
||
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
||
using the manual pages.<BR>
|
||
Time: 00:05:17 GMT, March 31, 2021
|
||
</BODY>
|
||
</HTML>
|