idna_to_ascii_4i(3)

πŸ’– idna_to_ascii_4i β€” a libidn moment πŸ’–

okay bestie, sit down, hydrate, because we're about to talk about idna_to_ascii_4i(3) from libidn. it's the API function that takes your cute little Unicode domain label and turns it into plain ASCII. it's giving translator, it's giving glow-up, it's giving IDN. let's GO πŸ¦‹


✨ NAME ✨

idna_to_ascii_4i β€” literally just an API function, no cap πŸ’…


✨ SYNOPSIS ✨

#include <idna.h>

int idna_to_ascii_4i(const uint32_t * in, size_t inlen, char * out, int
flags);

yes the line break in the middle of flags is real, we don't make the rules, we just copy them exactly πŸŽ€


✨ ARGUMENTS ✨

  • const uint32_t * in β€” the input array, and it's full of Unicode code points. that's the whole vibe. 🌸
  • size_t inlen β€” how long that input array of Unicode code points is. count them, bestie.
  • char * out β€” the output, a zero-terminated string. IMPORTANT: it must have room for at least 63 characters plus the terminating zero. that is not a suggestion, that is a boundary, and you will respect her πŸ‘‘
  • int flags β€” an Idna_flags value. for example IDNA_ALLOW_UNASSIGNED or IDNA_USE_STD3_ASCII_RULES. pick your fighter ✨

✨ 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). and if ToASCII succeeds? the original sequence and the resulting sequence are equivalent labels. slay. ✨

okay but listen: ToASCII can fail. and not in a cute way. 😭

It is important to note that the ToASCII operation can fail. ToASCII fails if any step of it fails. 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. the way you deal with that failure is application-specific, so that's on you, babe. (also yes, the original says "deadling" β€” typo and all, we're preserving the lore 🫢)

The inputs to ToASCII are a sequence of code points, the AllowUnassigned flag, and the UseSTD3ASCIIRules flag. The output of ToASCII is either a sequence of ASCII code points or a failure condition. that's it. two outcomes. iconic.

ToASCII never alters a sequence of code points that are all in the ASCII range to begin with (although it could fail β€” rude). And applying the ToASCII operation multiple times has exactly the same effect as applying it just once. idempotent queen πŸ‘‘

Return value: Returns 0 on success, or an Idna_rc error code. zero is the good one. anything else? read the room. πŸ’€


πŸ› REPORTING BUGS πŸ›

found a bug? don't suffer in silence, tell the people:


Copyright Β© 2002-2026 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: share it, remix it, just keep the receipts. free of charge, free of drama πŸ’œ)


πŸ‘€ SEE ALSO πŸ‘€

The full documentation for libidn is maintained as a Texinfo manual. If the info and libidn programs are properly installed at your site, the command

info libidn

should give you access to the complete manual. As an alternative you may obtain the manual from:

https://www.gnu.org/software/libidn/manual/

iykyk 🌈


and that's the whole page, bestie. this one's from libidn, version 1.44, manual section 3, and we are obsessed. go forth and ASCII-fy responsibly πŸŽ€πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from