iconv1
Codeset conversion utility
Usage
iconv [-cs]
-f
from_name
-t
to_name
[file ...]
iconv -f
from_name
[-cs]
[-t
to_name]
[file ...]
iconv -t
to_name
[-cs]
[-f
from_name]
[file ...]
iconv -l
Overview
The iconv utility converts the codeset of file (or from standard input if no file is specified) from codeset from_name to codeset to_name and outputs the converted text on standard output.
The following options are available:
-
-c -
Prevent output of any invalid characters. By default,
iconvoutputs an “invalid character” specified by the to_name codeset when it encounts a character which is valid in the from_name codeset but does not have a corresponding character in the to_name codeset. -
-f -
Specifies the source codeset name as from_name.
-
-l -
Lists available codeset names. Note that not all combinations of from_name and to_name are valid.
-
-s -
Silent. By default,
iconvoutputs the number of “invalid characters” to standard error if they exist. This option prevents this behaviour. -
-t -
Specifies the destination codeset name as to_name.
Exit status
The iconv utility exits 0 on success, and >0 if an error occurs.
Examples
Convert file.txt from IBM273 to UTF-8 and save the result to converted.txt:
iconv -f IBM273 -t UTF-8 file.txt > converted.txt
Releases
145 releases since Mac OS X 10.3; the text changed 2 times.
-c since Mac OS X 10.5;
-f since Mac OS X 10.5;
-l since macOS 14.0;
-s since Mac OS X 10.5;
-t since Mac OS X 10.5.
--byte-subst until macOS 13.5;
--from-code until macOS 13.5;
--silent until macOS 13.5;
--to-code until macOS 13.5;
--unicode-subst until macOS 13.5;
--widechar-subst until macOS 13.5.