idn2_to_ascii_4i(3)
β¨ NAME β¨
okay so bestie, we're looking at idn2_to_ascii_4i β it's an API function from the libidn2 manual (section 3, library calls, iykyk π
). it does the ToASCII thing. that's the whole vibe.
πΈ SYNOPSIS πΈ
#include <idn2.h>
int idn2_to_ascii_4i(const uint32_t * input, size_t inlen, char *
output, int flags);
like, yes, the line break is mid-declaration, that's just how it's printed, we respect it π«Ά
π ARGUMENTS π
const uint32_t * inputβ the input, fr. a zero terminated Unicode (UCS-4) string. UCS-4!! that's the big one, 32 bits per character, no skimping πsize_t inlenβ how many elements are ininput. count them. literally count them.char * outputβ the output zero terminated string. and babes, listen, this buffer has to have room for at least 63 characters plus the terminating zero. 63. plus the zero. do not be cute about it, allocate enough or it's giving undefined behaviour πint flagsβ optionalidn2_flagsto modify behaviour. optional!! zero means "defaults, bestie" β¨
π¦ DESCRIPTION π¦
so the ToASCII operation takes a sequence of Unicode code points that make up one domain label and transforms it into a sequence of code points in the ASCII range (0..7F). if ToASCII succeeds, the original sequence and the resulting sequence are equivalent labels. that's the whole point. iconic.
now the serious part, and I need you to actually read this one:
ToASCII can fail. it fails if any step of it fails. and if any step of the ToASCII operation fails on any label in a domain name, that domain name MUST NOT be used as an internationalized domain name. periodt. what you do about that failure is application-specific β that's on you and your app, not on this function.
the inputs to ToASCII are a sequence of code points. that's it. that's the input. π
ToASCII never alters a sequence of code points that are all in the ASCII range to begin with (although, ok, it could still fail β no promises, bestie). and applying the ToASCII operation multiple times has the same effect as applying it just once. idempotent queen π
the default behavior of this function (when flags are zero) is to apply the IDNA2008 rules without the TR46 amendments. but here's the tea: TR46 non-transitional processing is nowadays ubiquitous, so when you're unsure, it is recommended that you call this function with the IDN2_NONTRANSITIONAL and the IDN2_NFC_INPUT flags for compatibility with other software. do with that what you will π
π WARNING π
okay so, from version 2.1.1 until before version 2.3.5, this function was deprecated in favor of idn2_to_ascii_4i2(). and even now we still encourage you to use idn2_to_ascii_4i2() when appropriate. she's the upgraded version, no cap. π«Ά
β RETURNS β
- on successful conversion,
IDN2_OKis returned π - if the output label would have been too long,
IDN2_TOO_BIG_LABELis returned π - or another error code is returned. there are others. it can be anything. that's the mystery of it β¨
π SINCE π
2.0.0. she's been here a minute.
π REPORTING BUGS π
found a bug? tell the people:
- Report bugs to
<help-libidn@gnu.org>. - General guidelines for reporting bugs:
https://www.gnu.org/gethelp/ - Libidn2 home page:
https://www.gnu.org/software/libidn2/
π COPYRIGHT π
Copyright Β© 2002-2025 Simon Josefsson.
Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved.
(translation: use it, share it, just keep the receipt π§Ύβ¨)
π SEE ALSO π
the full documentation for libidn2 is maintained as a Texinfo manual. if the info and libidn2 programs are properly installed at your site, this command:
info libidn2
should give you access to the complete manual. and as an alternative you may obtain the manual from:
https://www.gnu.org/software/libidn/libidn2/manual/
okay that's the whole page bestie, go forth and convert your labels responsibly π
this has been libidn2 version 2.3.8, dated idn2_to_ascii_4i(3) era β mwah, slay, bye ππ
π¦ where this page comes from
- alpine 3.23: libidn2-doc 2.3.8-r0 Β· GPL-2.0-or-later OR LGPL-3.0-or-later
- alpine 3.24: libidn2-doc 2.3.8-r0 Β· GPL-2.0-or-later OR LGPL-3.0-or-later
- arch rolling: libidn2 2.3.8-1 Β· GPL2 AND LGPL3
- debian trixie: libidn2-dev 2.3.8-2 Β· GPL-3.0-or-later
- fedora 43: libidn2-devel 2.3.8-2.fc43 Β· (GPL-2.0-or-later OR LGPL-3.0-or-later) AND GPL-3.0-or-later
- fedora 43: libidn2-devel 2.3.8-2.fc43 Β· (GPL-2.0-or-later OR LGPL-3.0-or-later) AND GPL-3.0-or-later
- fedora 44: libidn2-devel 2.3.8-3.fc44 Β· (GPL-2.0-or-later OR LGPL-3.0-or-later) AND GPL-3.0-or-later
- fedora 44: libidn2-devel 2.3.8-3.fc44 Β· (GPL-2.0-or-later OR LGPL-3.0-or-later) AND GPL-3.0-or-later
- opensuse-leap 16.0: libidn2-devel 2.3.8-160000.2.2 Β· (GPL-2.0-or-later OR LGPL-3.0-or-later) AND GPL-3.0-or-later
- opensuse-leap 16.0: libidn2-devel 2.3.8-160000.2.2 Β· (GPL-2.0-or-later OR LGPL-3.0-or-later) AND GPL-3.0-or-later
- opensuse-leap 16.0: libidn2-devel 2.3.8-160000.2.2 Β· (GPL-2.0-or-later OR LGPL-3.0-or-later) AND GPL-3.0-or-later
- opensuse-leap 16.0: libidn2-devel 2.3.8-160000.2.2 Β· (GPL-2.0-or-later OR LGPL-3.0-or-later) AND GPL-3.0-or-later
- ubuntu questing: libidn2-dev 2.3.8-4
- ubuntu resolute: libidn2-dev 2.3.8-4build1 Β· GPL-3.0-or-later
- ubuntu stonking: libidn2-dev 2.3.8-5 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms