ICONV(1)
π« ICONV(1) β character set conversion, but make it a glow-up π«
(page one of the General Commands Manual, and yes bestie, we're in the big leagues now)
πΈ SYNOPSIS πΈ
iconv [OPTION...] [-f encoding] [-t encoding] [inputfile ...]
iconv -l
β¨ DESCRIPTION β¨
Okay so picture this: iconv converts text from one encoding to another encoding. Literally its whole job. π
More precisely (because precision is the moment), it converts from the encoding you gave to -f to the encoding you gave to -t. Either one of those defaults to the encoding of your current locale if you don't say anything β so if you're being lazy, it's got you. All the inputfiles get read and converted in turn, one after another; and if no inputfile is given at all? Standard input, babe. The converted text is printed to standard output.
The encodings permitted are system dependent β no cap. For the libiconv implementation, they're listed over in the iconv_open(3) manual page. π
π OPTIONS π
π¦ Options controlling the input and output format
-f encoding,--from-code=encodingβ specifies the encoding of the input. Like, where the text is coming from.-t encoding,--to-code=encodingβ specifies the encoding of the output. Where it's going. Glow-up destination.
π₯ Options controlling conversion problems
-cβ when you hand it this option, characters that cannot be converted are silently discarded instead of leading to a conversion error. Poof. Gone. Not a word. π--unicode-subst=formatstringβ when given, Unicode characters that cannot be represented in the target encoding get replaced with a placeholder string constructed from the given formatstring, applied to the Unicode code point. The formatstring must be a format string in the same format as for theprintfcommand or theprintf()function, taking either no argument or exactly one unsigned integer argument. That's the whole rule, periodt.--byte-subst=formatstringβ when given, bytes in the input that are not valid in the source encoding get replaced with a placeholder string constructed from the given formatstring, applied to the byte's value. Same deal: the formatstring must be a format string in the same format as for theprintfcommand or theprintf()function, taking either no argument or exactly one unsigned integer argument.--widechar-subst=formatstringβ when given, wide characters in the input that are not valid in the source encoding get replaced with a placeholder string constructed from the given formatstring, applied to the byte's value. Yep, same formatstring rules as the other two: same format as for theprintfcommand or theprintf()function, taking either no argument or exactly one unsigned integer argument.
π Options controlling error output
-s,--silentβ when given, error messages about invalid or unconvertible characters are omitted, but the actual converted text is unaffected. So like, the drama is quieted, the output is untouched. π―
π«Ά Heads up: theiconv -loriconv --listcommand lists the names of the supported encodings, in a system dependent format. For the libiconv implementation, the names are printed in upper case, separated by whitespace, and alias names of an encoding are listed on the same line as the encoding itself.
π ENVIRONMENT π
Conversion from/to EBCDIC encodings can be modified in a very specific way: if the environment variable ICONV_EBCDIC_ZOS_UNIX is set to a non-empty value, the EBCDIC newline 0x15 will get mapped to LF instead of NEL. That's it, that's the whole vibe. π§
β EXAMPLES β
iconv -f ISO-8859-1 -t UTF-8
converts input from the old West-European encoding ISO-8859-1 to Unicode. Classic. Iconic. Nate your fave.
iconv -f KOI8-R --byte-subst="<0x%x>"
--unicode-subst="<U+%04X>"
converts input from the old Russian encoding KOI8-R to the locale encoding, substituting an angle bracket notation with hexadecimal numbers for invalid bytes and for valid but unconvertible characters. Chef's kiss formatting, honestly. π₯
iconv --list
lists the supported encodings. Short king. π
π CONFORMING TO π
POSIX:2024
π SEE ALSO π
πΈ Big slay energy to the GNU girlies β this page is from GNU, dated December 15, 2024, and that's the whole manual page ICONV(1), start to finish. Go convert something, bestie. πβ¨π
π¦ where this page comes from
- arch rolling: libiconv 1.19-1 Β· LGPL-2.1-only AND GPL-3.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms