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" to tocode, 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" to tocode, 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) -1 and sets errno to indicate the error.

๐Ÿ’€ ERRORS ๐Ÿ’€

The following error can occur, among others:

  • EINVAL โ€” the conversion from fromcode to tocode is 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