iconvconvert characters from one code set to another |
Command |
iconv
[-sc
]
-f
oldset
-t
newset
[file ...]
iconv
-l
[-v
]
iconv
command converts characters in file (or
from standard input if no file is specified) from one code set to another.
The converted text is written to standard output. iconv
uses
both code sets stored in internal tables and code sets in stored as external
files. When a code set is specified, iconv
first searches
its internal table. If the code set is not in the internal table and the code
set name is an absolute path name, iconv
looks for that file.
If the code set is not in the internal table and the file looks like a relative
path name, iconv
treats it as a file name in the directory
library/iconv
, where library is the library directory.
If the input contains a character which is invalid in the source code set,
iconv
replaces it with the byte 0xff
and
continues, unless the -c
option is specified. If the input
contains a character which is invalid in the destination code set,
iconv
replaces it with the underscore character
(_
) in the destination code set, and continues.
-c
cleans away characters which had conversion errors; these characters
are not written to the output. By default, characters not in the source
character set are converted to the value 0xff
and written to
the output.
-f
oldsetspecifies the current code set of the input. oldset can be either the code set name or a path name to a file containing an external code set.
-l
lists code sets in the internal table. This option is not available on
all systems; it depends upon the system's implementation of the
iconv()
function.
-s
suppresses all error messages about faulty encodings.
-t
newsetspecifies the destination code set for the output. newset can be either the code set name or a path name to a file containing an external code set.
-v
specifies verbose output. When used with -l
, the
list of code sets includes brief explanatory names.
words.txt
from the ISO 8859-1 standard code set
to the CP 437 standard code set, and store in converted
:
iconv -f ISO8859-1 -t CP437 words.txt > converted
0
Successful completion.
1
Failure due to any of the following:
2
Input contained a character sequence which is illegal in the source code set.
-v
and the ability to specify file names as arguments to
-f
and -t
are all extensions to the XPG
standard and are proposed extensions to the POSIX.2b standard.
The -c
, -l
, and -s
options are extensions to the XPG standard.
iconv