ICONV(1P)
π ICONV π β codeset conversion, but make it a glow-up for your text files
okay bestie, so this page is from the POSIX Programmer's Manual (the iconv(1P) girlies know), and listen β the Linux version of this interface might be different (so go check the Linux manual page for the real Linux tea), or it might not even be implemented on Linux at all. π
β¨ NAME β¨
iconv β codeset conversion. that's it, that's the whole vibe. π
π¦ SYNOPSIS π¦
iconv [-cs] -f frommap -t tomap [file...]
iconv -f fromcode [-cs] [-t tocode] [file...]
iconv -t tocode [-cs] [-f fromcode] [file...]
iconv -l
four whole moods, pick your fighter. β¨
πΈ DESCRIPTION πΈ
the iconv utility shall convert the encoding of characters in file from one codeset to another and write the results to standard output. literally a character makeover. π₯
when the options indicate that charmap files are used to specify the codesets (see OPTIONS), the codeset conversion shall be accomplished by performing a logical join on the symbolic character names in the two charmaps. the implementation need not support the use of charmap files for codeset conversion unless the POSIX2_LOCALEDEF symbol is defined on the system. so like, sometimes it just can't, no cap. π
π OPTIONS π
the iconv utility shall conform to the Base Definitions volume of POSIX.1β2017, Section 12.2, Utility Syntax Guidelines. yes ma'am, rules are rules.
the following options shall be supported:
-cβ omit any characters that are invalid in the codeset of the input file from the output. when-cis not used, the results of encountering invalid characters in the input stream (either those that are not characters in the codeset of the input file or that have no corresponding character in the codeset of the output file) shall be specified in the system documentation. the presence or absence of-cshall not affect the exit status oficonv. so like, it filters the messy bits, but it does not change your grade. periodt.-ffromcodeset β identify the codeset of the input file. the implementation shall recognize the following two forms of the fromcodeset option-argument:- fromcode β the fromcode option-argument must not contain a
<slash>character. it shall be interpreted as the name of one of the codeset descriptions provided by the implementation in an unspecified format. valid values of fromcode are implementation-defined. (so, like, ask your system, not me π) - frommap β the frommap option-argument must contain a
<slash>character. it shall be interpreted as the pathname of a charmap file as defined in the Base Definitions volume of POSIX.1β2017, Section 6.4, Character Set Description File. if the pathname does not represent a valid, readable charmap file, the results are undefined. π¨ - if this option is omitted, the codeset of the current locale shall be used.
- fromcode β the fromcode option-argument must not contain a
-lβ write all supported fromcode and tocode values to standard output in an unspecified format. it's giving "show me the menu". π-sβ suppress any messages written to standard error concerning invalid characters. when-sis not used, the results of encountering invalid characters in the input stream (either those that are not valid characters in the codeset of the input file or that have no corresponding character in the codeset of the output file) shall be specified in the system documentation. the presence or absence of-sshall not affect the exit status oficonv. shhh, no drama in the error log. π€«-ttocodeset β identify the codeset to be used for the output file. the implementation shall recognize the following two forms of the tocodeset option-argument:- tocode β the semantics shall be equivalent to the
-ffromcode option. - tomap β the semantics shall be equivalent to the
-ffrommap option. - if this option is omitted, the codeset of the current locale shall be used.
- tocode β the semantics shall be equivalent to the
β οΈ if either-for-trepresents a charmap file, but the other does not (or is omitted), or both-fand-tare omitted, the results are undefined. bestie. do not do this. i am begging. π
π OPERANDS π
the following operand shall be supported:
- file β a pathname of an input file. if no file operands are specified, or if a file operand is
'-', the standard input shall be used.
β STDIN β
the standard input shall be used only if no file operands are specified, or if a file operand is '-'.
π INPUT FILES π
the input file shall be a text file. just text. that's the whole requirement. π«Ά
π ENVIRONMENT VARIABLES π
the following environment variables shall affect the execution of iconv:
LANGβ provide a default value for the internationalization variables that are unset or null. (see the Base Definitions volume of POSIX.1β2017, Section 8.2, Internationalization Variables for the precedence of internationalization variables used to determine the values of locale categories.)LC_ALLβ if set to a non-empty string value, override the values of all the other internationalization variables. main character energy, overrides everyone.LC_CTYPEβ determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multi-byte characters in arguments). during translation of the file, this variable is superseded by the use of the fromcode option-argument. so-fsteals the spotlight, iconic.LC_MESSAGESβ determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.NLSPATHβ determine the location of message catalogs for the processing ofLC_MESSAGES.
π§ ASYNCHRONOUS EVENTS π§
Default. (yes queen, keep it default π )
β¨ STDOUT β¨
when the -l option is used, the standard output shall contain all supported fromcode and tocode values, written in an unspecified format.
when the -l option is not used, the standard output shall contain the sequence of characters read from the input files, translated to the specified codeset. nothing else shall be written to the standard output. nothing. nada. zero. π
π STDERR π
the standard error shall be used only for diagnostic messages.
π OUTPUT FILES π
None. nothing. empty. the void. β¨
π¦ EXTENDED DESCRIPTION π¦
None.
π₯ EXIT STATUS π₯
the following exit values shall be returned:
0β successful completion. slay. π>0β an error occurred. π
πΈ CONSEQUENCES OF ERRORS πΈ
Default.
the following sections are informative. (iykyk β informative means it's lore, not law π)
π APPLICATION USAGE π
the user must ensure that both charmap files use the same symbolic names for characters the two codesets have in common. like, if they're not speaking the same language, that's on you bestie. π«Ά
β EXAMPLES β
the following example converts the contents of file mail.x400 from the ISO/IEC 6937:2001 standard codeset to the ISO/IEC 8859β1:1998 standard codeset, and stores the results in file mail.local:
iconv -f IS6937 -t IS8859 mail.x400 > mail.local
ate that. no crumbs. π₯
π RATIONALE π
the iconv utility can be used portably only when the user provides two charmap files as option-arguments. this is because a single charmap provided by the user cannot reliably be joined with the names in a system-provided character set description. the valid values for fromcode and tocode are implementation-defined and do not have to have any relation to the charmap mechanisms. as an aid to interactive users, the -l option was adopted from the Plan 9 operating system. it writes information concerning these implementation-defined values. the format is unspecified because there are many possible useful formats that could be chosen, such as a matrix of valid combinations of fromcode and tocode. the -l option is not intended for shell script usage; conforming applications will have to use charmaps. so like, -l is for you to peek at, not for your scripts to depend on. noted. π
the iconv utility may support the conversion between ASCII and EBCDIC-based encodings, but is not required to do so. in an XSI-compliant implementation, the dd utility is the only method guaranteed to support conversion between these two character sets. so if you need that ASCIIβEBCDIC flip, dd is the one who actually shows up. π
π FUTURE DIRECTIONS π
None.
π SEE ALSO π
ddgencat- The Base Definitions volume of POSIX.1β2017, Section 6.4, Character Set Description File, Chapter 8, Environment Variables, Section 12.2, Utility Syntax Guidelines
π COPYRIGHT π
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
and that's the whole page bestie π brought to you by IEEE/The Open Group, 2017, and the letter I for iconv. go convert something gorgeous. π¦β¨π
π¦ where this page comes from
- alpine 3.22: man-pages-posix 2017a-r0 Β· custom
- alpine 3.23: man-pages-posix 2017a-r0 Β· custom
- alpine 3.24: man-pages-posix 2017a-r0 Β· custom
- arch rolling: man-pages 6.19-1
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages-posix 2017a
- opensuse-leap 16.0: man-pages-posix 2017a-160000.4.1 Β· SUSE-IEEE
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms