1ICONV(1P)                  POSIX Programmer's Manual                 ICONV(1P)
2
3
4

PROLOG

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
11

NAME

13       iconv — codeset conversion
14

SYNOPSIS

16       iconv [−cs] −f frommap −t tomap [file...]
17
18       iconv −f fromcode [−cs] [−t tocode] [file...]
19
20       iconv −t tocode [−cs] [−f fromcode] [file...]
21
22       iconv −l
23

DESCRIPTION

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

OPTIONS

36       The iconv utility shall conform  to  the  Base  Definitions  volume  of
37       POSIX.1‐2008, 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
42                 input file from the output. When −c is not used, the  results
43                 of  encountering  invalid  characters  in  the  input  stream
44                 (either those that are not characters in the codeset  of  the
45                 input  file  or  that  have no corresponding character in the
46                 codeset of the output file) shall be specified in the  system
47                 documentation. The presence or absence of −c shall not affect
48                 the exit status of iconv.
49
50       −f fromcodeset
51                 Identify the codeset of the input  file.  The  implementation
52                 shall  recognize  the  following two forms of the fromcodeset
53                 option-argument:
54
55                 fromcode  The fromcode option-argument  must  not  contain  a
56                           <slash>  character.  It shall be interpreted as the
57                           name of one of the codeset descriptions provided by
58                           the  implementation in an unspecified format. Valid
59                           values of fromcode are implementation-defined.
60
61                 frommap   The frommap option-argument must contain a  <slash>
62                           character.  It shall be interpreted as the pathname
63                           of a charmap file as defined in  the  Base  Defini‐
64                           tions  volume of POSIX.1‐2008, Section 6.4, Charac‐
65                           ter Set Description File.  If the pathname does not
66                           represent  a  valid,  readable  charmap  file,  the
67                           results are undefined.
68
69                 If this option is omitted, the codeset of the current  locale
70                 shall be used.
71
72       −l        Write  all  supported  fromcode and tocode values to standard
73                 output in an unspecified format.
74
75       −s        Suppress any messages written to  standard  error  concerning
76                 invalid  characters.  When  −s  is  not  used, the results of
77                 encountering invalid characters in the input  stream  (either
78                 those  that  are  not  valid characters in the codeset of the
79                 input file or that have no  corresponding  character  in  the
80                 codeset  of the output file) shall be specified in the system
81                 documentation. The presence or absence of −s shall not affect
82                 the exit status of iconv.
83
84       −t tocodeset
85                 Identify  the  codeset  to  be  used for the output file. The
86                 implementation shall recognize the following two forms of the
87                 tocodeset option-argument:
88
89                 tocode    The  semantics  shall be equivalent to the −f from‐
90                           code option.
91
92                 tomap     The semantics shall be equivalent to the −f frommap
93                           option.
94
95                 If  this option is omitted, the codeset of the current locale
96                 shall be used.
97
98       If either −f or −t represents a charmap file, but the  other  does  not
99       (or  is  omitted), or both −f and −t are omitted, the results are unde‐
100       fined.
101

OPERANDS

103       The following operand shall be supported:
104
105       file      A pathname of an input file. If no file operands  are  speci‐
106                 fied,  or  if a file operand is '−', the standard input shall
107                 be used.
108

STDIN

110       The standard input shall be used only if no file  operands  are  speci‐
111       fied, or if a file operand is '−'.
112

INPUT FILES

114       The input file shall be a text file.
115

ENVIRONMENT VARIABLES

117       The  following  environment  variables  shall  affect  the execution of
118       iconv:
119
120       LANG      Provide a default value for  the  internationalization  vari‐
121                 ables  that are unset or null. (See the Base Definitions vol‐
122                 ume of POSIX.1‐2008, Section 8.2, Internationalization  Vari‐
123                 ables  for  the  precedence of internationalization variables
124                 used to determine the values of locale categories.)
125
126       LC_ALL    If set to a non-empty string value, override  the  values  of
127                 all the other internationalization variables.
128
129       LC_CTYPE  Determine  the  locale for the interpretation of sequences of
130                 bytes of text data as characters (for example, single-byte as
131                 opposed to multi-byte characters in arguments). During trans‐
132                 lation of the file, this variable is superseded by the use of
133                 the fromcode option-argument.
134
135       LC_MESSAGES
136                 Determine the locale that should be used to affect the format
137                 and contents  of  diagnostic  messages  written  to  standard
138                 error.
139
140       NLSPATH   Determine the location of message catalogs for the processing
141                 of LC_MESSAGES.
142

ASYNCHRONOUS EVENTS

144       Default.
145

STDOUT

147       When the −l option is used, the standard output shall contain all  sup‐
148       ported fromcode and tocode values, written in an unspecified format.
149
150       When  the  −l option is not used, the standard output shall contain the
151       sequence of characters read from the input  files,  translated  to  the
152       specified  codeset.  Nothing else shall be written to the standard out‐
153       put.
154

STDERR

156       The standard error shall be used only for diagnostic messages.
157

OUTPUT FILES

159       None.
160

EXTENDED DESCRIPTION

162       None.
163

EXIT STATUS

165       The following exit values shall be returned:
166
167        0    Successful completion.
168
169       >0    An error occurred.
170

CONSEQUENCES OF ERRORS

172       Default.
173
174       The following sections are informative.
175

APPLICATION USAGE

177       The user must ensure that both charmap  files  use  the  same  symbolic
178       names for characters the two codesets have in common.
179

EXAMPLES

181       The  following example converts the contents of file mail.x400 from the
182       ISO/IEC 6937:2001 standard codeset to the ISO/IEC 8859‐1:1998  standard
183       codeset, and stores the results in file mail.local:
184
185           iconv −f IS6937 −t IS8859 mail.x400 > mail.local
186

RATIONALE

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

FUTURE DIRECTIONS

207       None.
208

SEE ALSO

210       dd, gencat
211
212       The Base Definitions volume of POSIX.1‐2008, 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, 2013 Edition, Standard for Information Technology
219       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
220       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
221       cal  and  Electronics  Engineers,  Inc  and  The  Open Group.  (This is
222       POSIX.1-2008 with the 2013 Technical Corrigendum  1  applied.)  In  the
223       event of any discrepancy between this version and the original IEEE and
224       The Open Group Standard, the original IEEE and The Open Group  Standard
225       is  the  referee document. The original Standard can be obtained online
226       at http://www.unix.org/online.html .
227
228       Any typographical or formatting errors that appear  in  this  page  are
229       most likely to have been introduced during the conversion of the source
230       files to man page format. To report such errors,  see  https://www.ker
231       nel.org/doc/man-pages/reporting_bugs.html .
232
233
234
235IEEE/The Open Group                  2013                            ICONV(1P)
Impressum