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
23
25 The iconv utility shall convert the encoding of characters in file from
26 one codeset to another and write the results to standard output.
27
28 When the options indicate that charmap files are used to specify the
29 codesets (see OPTIONS), the codeset conversion shall be accomplished by
30 performing a logical join on the symbolic character names in the two
31 charmaps. The implementation need not support the use of charmap files
32 for codeset conversion unless the POSIX2_LOCALEDEF symbol is defined on
33 the system.
34
36 The iconv utility shall conform to the Base Definitions volume of
37 IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines.
38
39 The following options shall be supported:
40
41 -c Omit any characters that are invalid in the codeset of the input
42 file from the output. When -c is not used, the results of
43 encountering invalid characters in the input stream (either
44 those that are not characters in the codeset of the input file
45 or that have no corresponding character in the codeset of the
46 output file) shall be specified in the system documentation. The
47 presence or absence of -c shall not affect the exit status of
48 iconv.
49
50 -f fromcodeset
51
52 Identify the codeset of the input file. The implementation shall
53 recognize the following two forms of the fromcodeset option-
54 argument:
55
56 fromcode
57 The fromcode option-argument must not contain a slash character.
58 It shall be interpreted as the name of one of the codeset
59 descriptions provided by the implementation in an unspecified
60 format. Valid values of fromcode are implementation-defined.
61
62 frommap
63 The frommap option-argument must contain a slash character. It
64 shall be interpreted as the pathname of a charmap file as
65 defined in the Base Definitions volume of IEEE Std 1003.1-2001,
66 Section 6.4, Character Set Description File. If the pathname
67 does not represent a valid, readable charmap file, the results
68 are undefined.
69
70
71 If this option is omitted, the codeset of the current locale shall be
72 used.
73
74 -l Write all supported fromcode and tocode values to standard out‐
75 put in an unspecified format.
76
77 -s Suppress any messages written to standard error concerning
78 invalid characters. When -s is not used, the results of encoun‐
79 tering invalid characters in the input stream (either those that
80 are not valid characters in the codeset of the input file or
81 that have no corresponding character in the codeset of the out‐
82 put file) shall be specified in the system documentation. The
83 presence or absence of -s shall not affect the exit status of
84 iconv.
85
86 -t tocodeset
87 Identify the codeset to be used for the output file. The imple‐
88 mentation shall recognize the following two forms of the tocode‐
89 set option-argument:
90
91 tocode
92 The semantics shall be equivalent to the -f fromcode option.
93
94 tomap
95 The semantics shall be equivalent to the tomap option.
96
97
98 If this option is omitted, the codeset of the current locale shall be
99 used.
100
101
102 If either -f or -t represents a charmap file, but the other does not
103 (or is omitted), or both -f and -t are omitted, the results are unde‐
104 fined.
105
107 The following operand shall be supported:
108
109 file A pathname of an input file. If no file operands are specified,
110 or if a file operand is '-', the standard input shall be used.
111
112
114 The standard input shall be used only if no file operands are speci‐
115 fied, or if a file operand is '-' .
116
118 The input file shall be a text file.
119
121 The following environment variables shall affect the execution of
122 iconv:
123
124 LANG Provide a default value for the internationalization variables
125 that are unset or null. (See the Base Definitions volume of
126 IEEE Std 1003.1-2001, Section 8.2, Internationalization Vari‐
127 ables for the precedence of internationalization variables used
128 to determine the values of locale categories.)
129
130 LC_ALL If set to a non-empty string value, override the values of all
131 the other internationalization variables.
132
133 LC_CTYPE
134 Determine the locale for the interpretation of sequences of
135 bytes of text data as characters (for example, single-byte as
136 opposed to multi-byte characters in arguments). During transla‐
137 tion of the file, this variable is superseded by the use of the
138 fromcode option-argument.
139
140 LC_MESSAGES
141 Determine the locale that should be used to affect the format
142 and contents of diagnostic messages written to standard error.
143
144 NLSPATH
145 Determine the location of message catalogs for the processing of
146 LC_MESSAGES .
147
148
150 Default.
151
153 When the -l option is used, the standard output shall contain all sup‐
154 ported fromcode and tocode values, written in an unspecified format.
155
156 When the -l option is not used, the standard output shall contain the
157 sequence of characters read from the input files, translated to the
158 specified codeset. Nothing else shall be written to the standard out‐
159 put.
160
162 The standard error shall be used only for diagnostic messages.
163
165 None.
166
168 None.
169
171 The following exit values shall be returned:
172
173 0 Successful completion.
174
175 >0 An error occurred.
176
177
179 Default.
180
181 The following sections are informative.
182
184 The user must ensure that both charmap files use the same symbolic
185 names for characters the two codesets have in common.
186
188 The following example converts the contents of file mail.x400 from the
189 ISO/IEC 6937:1994 standard codeset to the ISO/IEC 8859-1:1998 standard
190 codeset, and stores the results in file mail.local:
191
192
193 iconv -f IS6937 -t IS8859 mail.x400 > mail.local
194
196 The iconv utility can be used portably only when the user provides two
197 charmap files as option-arguments. This is because a single charmap
198 provided by the user cannot reliably be joined with the names in a sys‐
199 tem-provided character set description. The valid values for fromcode
200 and tocode are implementation-defined and do not have to have any rela‐
201 tion to the charmap mechanisms. As an aid to interactive users, the -l
202 option was adopted from the Plan 9 operating system. It writes informa‐
203 tion concerning these implementation-defined values. The format is
204 unspecified because there are many possible useful formats that could
205 be chosen, such as a matrix of valid combinations of fromcode and
206 tocode. The -l option is not intended for shell script usage; conform‐
207 ing applications will have to use charmaps.
208
210 None.
211
213 gencat
214
216 Portions of this text are reprinted and reproduced in electronic form
217 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
218 -- Portable Operating System Interface (POSIX), The Open Group Base
219 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
220 Electrical and Electronics Engineers, Inc and The Open Group. In the
221 event of any discrepancy between this version and the original IEEE and
222 The Open Group Standard, the original IEEE and The Open Group Standard
223 is the referee document. The original Standard can be obtained online
224 at http://www.opengroup.org/unix/online.html .
225
226
227
228IEEE/The Open Group 2003 ICONV(1P)