1ICONV(1P) POSIX Programmer's Manual ICONV(1P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
12 iconv — codeset conversion
13
15 iconv [-cs] -f frommap -t tomap [file...]
16
17 iconv -f fromcode [-cs] [-t tocode] [file...]
18
19 iconv -t tocode [-cs] [-f fromcode] [file...]
20
21 iconv -l
22
24 The iconv utility shall convert the encoding of characters in file from
25 one codeset to another and write the results to standard output.
26
27 When the options indicate that charmap files are used to specify the
28 codesets (see OPTIONS), the codeset conversion shall be accomplished by
29 performing a logical join on the symbolic character names in the two
30 charmaps. The implementation need not support the use of charmap files
31 for codeset conversion unless the POSIX2_LOCALEDEF symbol is defined on
32 the system.
33
35 The iconv utility shall conform to the Base Definitions volume of
36 POSIX.1‐2017, Section 12.2, Utility Syntax Guidelines.
37
38 The following options shall be supported:
39
40 -c Omit any characters that are invalid in the codeset of the
41 input file from the output. When -c is not used, the results
42 of encountering invalid characters in the input stream
43 (either those that are not characters in the codeset of the
44 input file or that have no corresponding character in the
45 codeset of the output file) shall be specified in the system
46 documentation. The presence or absence of -c shall not affect
47 the exit status of iconv.
48
49 -f fromcodeset
50 Identify the codeset of the input file. The implementation
51 shall recognize the following two forms of the fromcodeset
52 option-argument:
53
54 fromcode The fromcode option-argument must not contain a
55 <slash> character. It shall be interpreted as the
56 name of one of the codeset descriptions provided by
57 the implementation in an unspecified format. Valid
58 values of fromcode are implementation-defined.
59
60 frommap The frommap option-argument must contain a <slash>
61 character. It shall be interpreted as the pathname
62 of a charmap file as defined in the Base Defini‐
63 tions volume of POSIX.1‐2017, Section 6.4, Charac‐
64 ter Set Description File. If the pathname does not
65 represent a valid, readable charmap file, the
66 results are undefined.
67
68 If this option is omitted, the codeset of the current locale
69 shall be used.
70
71 -l Write all supported fromcode and tocode values to standard
72 output in an unspecified format.
73
74 -s Suppress any messages written to standard error concerning
75 invalid characters. When -s is not used, the results of
76 encountering invalid characters in the input stream (either
77 those that are not valid characters in the codeset of the
78 input file or that have no corresponding character in the
79 codeset of the output file) shall be specified in the system
80 documentation. The presence or absence of -s shall not affect
81 the exit status of iconv.
82
83 -t tocodeset
84 Identify the codeset to be used for the output file. The
85 implementation shall recognize the following two forms of the
86 tocodeset option-argument:
87
88 tocode The semantics shall be equivalent to the -f from‐
89 code option.
90
91 tomap The semantics shall be equivalent to the -f frommap
92 option.
93
94 If this option is omitted, the codeset of the current locale
95 shall be used.
96
97 If either -f or -t represents a charmap file, but the other does not
98 (or is omitted), or both -f and -t are omitted, the results are unde‐
99 fined.
100
102 The following operand shall be supported:
103
104 file A pathname of an input file. If no file operands are speci‐
105 fied, or if a file operand is '-', the standard input shall
106 be used.
107
109 The standard input shall be used only if no file operands are speci‐
110 fied, or if a file operand is '-'.
111
113 The input file shall be a text file.
114
116 The following environment variables shall affect the execution of
117 iconv:
118
119 LANG Provide a default value for the internationalization vari‐
120 ables that are unset or null. (See the Base Definitions vol‐
121 ume of POSIX.1‐2017, Section 8.2, Internationalization Vari‐
122 ables for the precedence of internationalization variables
123 used to determine the values of locale categories.)
124
125 LC_ALL If set to a non-empty string value, override the values of
126 all the other internationalization variables.
127
128 LC_CTYPE Determine the locale for the interpretation of sequences of
129 bytes of text data as characters (for example, single-byte as
130 opposed to multi-byte characters in arguments). During trans‐
131 lation of the file, this variable is superseded by the use of
132 the fromcode option-argument.
133
134 LC_MESSAGES
135 Determine the locale that should be used to affect the format
136 and contents of diagnostic messages written to standard
137 error.
138
139 NLSPATH Determine the location of message catalogs for the processing
140 of LC_MESSAGES.
141
143 Default.
144
146 When the -l option is used, the standard output shall contain all sup‐
147 ported fromcode and tocode values, written in an unspecified format.
148
149 When the -l option is not used, the standard output shall contain the
150 sequence of characters read from the input files, translated to the
151 specified codeset. Nothing else shall be written to the standard out‐
152 put.
153
155 The standard error shall be used only for diagnostic messages.
156
158 None.
159
161 None.
162
164 The following exit values shall be returned:
165
166 0 Successful completion.
167
168 >0 An error occurred.
169
171 Default.
172
173 The following sections are informative.
174
176 The user must ensure that both charmap files use the same symbolic
177 names for characters the two codesets have in common.
178
180 The following example converts the contents of file mail.x400 from the
181 ISO/IEC 6937:2001 standard codeset to the ISO/IEC 8859‐1:1998 standard
182 codeset, and stores the results in file mail.local:
183
184
185 iconv -f IS6937 -t IS8859 mail.x400 > mail.local
186
188 The iconv utility can be used portably only when the user provides two
189 charmap files as option-arguments. This is because a single charmap
190 provided by the user cannot reliably be joined with the names in a sys‐
191 tem-provided character set description. The valid values for fromcode
192 and tocode are implementation-defined and do not have to have any rela‐
193 tion to the charmap mechanisms. As an aid to interactive users, the -l
194 option was adopted from the Plan 9 operating system. It writes informa‐
195 tion concerning these implementation-defined values. The format is
196 unspecified because there are many possible useful formats that could
197 be chosen, such as a matrix of valid combinations of fromcode and
198 tocode. The -l option is not intended for shell script usage; conform‐
199 ing applications will have to use charmaps.
200
201 The iconv utility may support the conversion between ASCII and EBCDIC-
202 based encodings, but is not required to do so. In an XSI-compliant
203 implementation, the dd utility is the only method guaranteed to support
204 conversion between these two character sets.
205
207 None.
208
210 dd, gencat
211
212 The Base Definitions volume of POSIX.1‐2017, Section 6.4, Character Set
213 Description File, Chapter 8, Environment Variables, Section 12.2, Util‐
214 ity Syntax Guidelines
215
217 Portions of this text are reprinted and reproduced in electronic form
218 from IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
219 table Operating System Interface (POSIX), The Open Group Base Specifi‐
220 cations Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of
221 Electrical and Electronics Engineers, Inc and The Open Group. In the
222 event of any discrepancy between this version and the original IEEE and
223 The Open Group Standard, the original IEEE and The Open Group Standard
224 is the referee document. The original Standard can be obtained online
225 at http://www.opengroup.org/unix/online.html .
226
227 Any typographical or formatting errors that appear in this page are
228 most likely to have been introduced during the conversion of the source
229 files to man page format. To report such errors, see https://www.ker‐
230 nel.org/doc/man-pages/reporting_bugs.html .
231
232
233
234IEEE/The Open Group 2017 ICONV(1P)