iconv_open(3)
โจ iconv_open(3) โ the Library Functions Manual glow-up โจ
okay bestie, we're in <iconv.h> land and this is the Library Functions Manual page for iconv_open, so buckle up ๐
๐ NAME ๐
iconv_open โ allocate descriptor for character set conversion
like. it literally just sets you up so you can convert text from one character encoding to another. she's the plug. ๐
๐ LIBRARY ๐
Standard C library (libc, -lc)
๐ธ SYNOPSIS ๐ธ
#include <iconv.h>
iconv_t iconv_open(const char *tocode, const char *fromcode);
๐ฆ DESCRIPTION ๐ฆ
So what iconv_open() does is she allocates a conversion descriptor โ a little handle โ that's suitable for converting byte sequences from the character encoding fromcode to the character encoding tocode. no cap, that's the whole job ๐
The values that are allowed for fromcode and tocode, and which combinations of them actually work, are system-dependent. Like, nobody's promising you the same menu everywhere. For the GNU C library though, the permitted values are listed by the iconv --list command, and ngl, all combinations of the listed values are supported. every single one. slay.
On top of that, the GNU C library and the GNU libiconv library both support the following two suffixes:
//TRANSLITโ when you append the string"//TRANSLIT"totocode, transliteration gets activated. What that means is: when some character can't be represented in the target character set, it can be approximated through one or several similarly looking characters. it's giving "close enough, we ball" ๐ซถ//IGNOREโ when you append the string"//IGNORE"totocode, characters that can't be represented in the target character set get silently discarded. gone. no warning, no note, just. gone. ๐
The conversion descriptor you get back can be used with iconv(3) any number of times. She stays valid until you deallocate her using iconv_close(3).
Also important: a conversion descriptor contains a conversion state. After creation using iconv_open(), that state is in the initial state. Using iconv(3) modifies the descriptor's conversion state. And if you wanna bring the state back to the initial state, you use iconv(3) with NULL as the inbuf argument. ๐
๐ RETURN VALUE ๐
- On success ๐:
iconv_open()returns a freshly allocated conversion descriptor. - On failure ๐ญ: it returns
(iconv_t) -1and setserrnoto indicate the error.
๐ ERRORS ๐
The following error can occur, among others:
EINVALโ the conversion fromfromcodetotocodeis not supported by the implementation.
"among others" is doing a LOT of heavy lifting in that sentence btw. don't assume this is the only one that can hit you ๐
๐ง ATTRIBUTES ๐ง
For an explanation of the terms used in this section, see attributes(7).
- Interface:
iconv_open() - Attribute: Thread safety
- Value:
MT-Safe locale
so yeah, thread-safe, but she's reading locale info, iykyk ๐
โญ STANDARDS โญ
POSIX.1-2008.
๐ HISTORY ๐
glibc 2.1. POSIX.1-2001, SUSv2.
๐ SEE ALSO ๐
iconv(1), iconv(3), iconv_close(3)
and that's the whole page, bestie ๐ this was the Linux man-pages 6.20 version, dated 2026-02-08, and honestly? iconic. go convert something. periodt ๐ฆโจ
๐ฆ where this page comes from
- 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 6.20
- ๐ the page's license: GPL-2.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms