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