]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man1/iconv.1
Changes: Ready for 5.02
[thirdparty/man-pages.git] / man1 / iconv.1
CommitLineData
111cf06c
MM
1'\" t -*- coding: UTF-8 -*-
2.\"
3.\" Copyright (C) 2014 Marko Myllynen <myllynen@redhat.com>
4.\"
5.\" %%%LICENSE_START(GPLv2+_DOC_FULL)
6.\" This is free documentation; you can redistribute it and/or
7.\" modify it under the terms of the GNU General Public License as
8.\" published by the Free Software Foundation; either version 2 of
9.\" the License, or (at your option) any later version.
10.\"
11.\" The GNU General Public License's references to "object code"
12.\" and "executables" are to be interpreted as the output of any
13.\" document formatting or typesetting system, including
14.\" intermediate and printed output.
15.\"
16.\" This manual is distributed in the hope that it will be useful,
17.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
18.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19.\" GNU General Public License for more details.
20.\"
21.\" You should have received a copy of the GNU General Public
22.\" License along with this manual; if not, see
23.\" <http://www.gnu.org/licenses/>.
24.\" %%%LICENSE_END
25.\"
9ba01802 26.TH ICONV 1 2019-03-06 "GNU" "Linux User Manual"
111cf06c
MM
27.SH NAME
28iconv \- convert text from one character encoding to another
29.SH SYNOPSIS
30.B iconv
31.RI [ options ]
20810608
JW
32.RI "[\-f " from-encoding "]"
33.RI "[\-t " to-encoding "]"
111cf06c
MM
34.RI [ inputfile ]...
35.SH DESCRIPTION
36The
37.B iconv
38program reads in text in one encoding and outputs the text in another
39encoding.
40If no input files are given, or if it is given as a dash (\-),
41.B iconv
3b1d2abe 42reads from standard input.
111cf06c
MM
43If no output file is given,
44.B iconv
3b1d2abe 45writes to standard output.
111cf06c
MM
46.PP
47If no
48.I from-encoding
49is given, the default is derived
50from the current locale's character encoding.
51If no
52.I to-encoding
53is given, the default is derived
54from the current locale's character
55encoding.
56.SH OPTIONS
57.TP
2e621720 58.BI \-f " from-encoding" "\fR, \fP\-\-from\-code=" from-encoding
111cf06c
MM
59Use
60.I from-encoding
61for input characters.
62.TP
2e621720 63.BI \-t " to-encoding" "\fR, \fP\-\-to\-code=" to-encoding
111cf06c
MM
64Use
65.I to-encoding
66for output characters.
2a86152e 67.IP
3b1d2abe 68If the string
a28b73cd 69.B //IGNORE
3b1d2abe
MK
70is appended to
71.IR to-encoding ,
111cf06c
MM
72characters that cannot be converted are discarded and an error is
73printed after conversion.
2a86152e 74.IP
3b1d2abe 75If the string
a28b73cd 76.B //TRANSLIT
3b1d2abe
MK
77is appended to
78.IR to-encoding ,
111cf06c 79characters being converted are transliterated when needed and possible.
3b1d2abe
MK
80This means that when a character cannot be represented in the target
81character set, it can be approximated through one or several similar
111cf06c
MM
82looking characters.
83Characters that are outside of the target character set and cannot be
84transliterated are replaced with a question mark (?) in the output.
85.TP
fb787570 86.BR \-l ", " \-\-list
111cf06c
MM
87List all known character set encodings.
88.TP
89.B "\-c"
90Silently discard characters that cannot be converted instead of
3b1d2abe 91terminating when encountering such characters.
111cf06c 92.TP
2e621720 93.BI \-o " outputfile" "\fR, \fP\-\-output=" outputfile
111cf06c
MM
94Use
95.I outputfile
96for output.
97.TP
fb787570 98.BR \-s ", " \-\-silent
3b1d2abe 99This option is ignored; it is provided only for compatibility.
111cf06c
MM
100.TP
101.B "\-\-verbose"
102Print progress information on standard error when processing
103multiple files.
104.TP
fb787570 105.BR \-? ", " \-\-help
111cf06c
MM
106Print a usage summary and exit.
107.TP
108.B "\-\-usage"
109Print a short usage summary and exit.
110.TP
fb787570 111.BR \-V ", " \-\-version
111cf06c
MM
112Print the version number, license, and disclaimer of warranty for
113.BR iconv .
114.SH EXIT STATUS
777411ae 115Zero on success, nonzero on errors.
111cf06c
MM
116.SH ENVIRONMENT
117Internally, the
118.B iconv
119program uses the
120.BR iconv (3)
121function which in turn uses
122.I gconv
7a1c8f56
MK
123modules (dynamically loaded shared libraries)
124to convert to and from a character set.
125Before calling
126.BR iconv (3),
91085d85 127the
111cf06c 128.B iconv
7a1c8f56
MK
129program must first allocate a conversion descriptor using
130.BR iconv_open (3).
131The operation of the latter function is influenced by the setting of the
111cf06c 132.B GCONV_PATH
7a1c8f56
MK
133environment variable:
134.IP * 3
135If
136.B GCONV_PATH
137is not set,
138.BR iconv_open (3)
538ca136 139loads the system gconv module configuration cache file created by
7a1c8f56
MK
140.BR iconvconfig (8)
141and then, based on the configuration,
142loads the gconv modules needed to perform the conversion.
538ca136
MM
143If the system gconv module configuration cache file is not available
144then the system gconv module configuration file is used.
7a1c8f56 145.IP *
111cf06c
MM
146If
147.B GCONV_PATH
7a1c8f56
MK
148is defined (as a colon-separated list of pathnames),
149the system gconv module configuration cache is not used.
150Instead,
151.BR iconv_open (3)
dfdbfcae 152first tries to load the configuration files by searching the directories in
a28b73cd 153.B GCONV_PATH
dfdbfcae
MK
154in order,
155followed by the system default gconv module configuration file.
7a1c8f56
MK
156If a directory does not contain a gconv module configuration file,
157any gconv modules that it may contain are ignored.
158If a directory contains a gconv module configuration file
159and it is determined that a module needed for this conversion is
160available in the directory,
161then the needed module is loaded from that directory,
162the order being such that the first suitable module found in
163.B GCONV_PATH
164is used.
165This allows users to use custom modules and even replace system-provided
166modules by providing such modules in
167.B GCONV_PATH
168directories.
111cf06c
MM
169.SH FILES
170.TP
171.I /usr/lib/gconv
172Usual default gconv module path.
173.TP
20810608 174.I /usr/lib/gconv/gconv\-modules
538ca136 175Usual system default gconv module configuration file.
111cf06c 176.TP
20810608 177.I /usr/lib/gconv/gconv\-modules.cache
538ca136 178Usual system gconv module configuration cache.
111cf06c
MM
179.SH CONFORMING TO
180POSIX.1-2001.
181.SH EXAMPLE
3b1d2abe 182Convert text from the ISO 8859-15 character encoding to UTF-8:
2a86152e 183.PP
3b1d2abe 184.in +4n
60d3774e 185.EX
20810608 186$ \fBiconv \-f ISO\-8859\-15 \-t UTF\-8 < input.txt > output.txt\fP
60d3774e 187.EE
3b1d2abe 188.in
111cf06c
MM
189.PP
190The next example converts from UTF-8 to ASCII, transliterating when
191possible:
2a86152e 192.PP
3b1d2abe 193.in +4n
60d3774e 194.EX
3b1d2abe 195$ \fBecho abc ß α € àḃç | iconv \-f UTF\-8 \-t ASCII//TRANSLIT\fP
111cf06c 196abc ss ? EUR abc
60d3774e 197.EE
3b1d2abe 198.in
d282bb24 199.SH SEE ALSO
111cf06c 200.BR locale (1),
2e51e29c 201.BR uconv (1),
111cf06c
MM
202.BR iconv (3),
203.BR nl_langinfo (3),
204.BR charsets (7),
205.BR iconvconfig (8)