punycode_decode(3)

✨ punycode_decode β€” the libidn glow-up πŸ’…

okay bestie, welcome to the punycode_decode(3) page from the libidn manual. yes it's an API function, yes it's gonna be fun, no cap. πŸ¦‹


🌸 NAME 🌸

punycode_decode β€” an API function. that's it, that's the name, slay. πŸ’–


✨ SYNOPSIS ✨

like, here's how you summon it:

#include <punycode.h>

int punycode_decode(size_t input_length, const char [] input, size_t *
output_length, punycode_uint [] output, unsigned char [] case_flags);

she returns an int, she takes five whole things, main character energy fr fr. πŸ‘‘


πŸŽ€ ARGUMENTS πŸŽ€

okay so these are the five besties you gotta hand over. no skipping, the way that each one matters is genuinely iconic.

  • size_t input_length β€” the number of ASCII code points chillin' in the input array. that's it. just the count. πŸ“
  • const char [] input β€” an array of ASCII code points, and we're talking 0..7F range only. keep it ASCII, bestie. 🌈
  • size_t * output_length β€” okay so this one is a two-way street and it's lowkey the most important. you pass IN the max number of code points you can receive into the output array β€” and that same number is also the max number of flags you can receive into the case_flags array, if case_flags isn't a NULL pointer. then, on a successful return, it'll hold the number of code points actually output (which is also the number of flags actually output, if case_flags isn't a null pointer). and here's the cute part: the decoder will never need to output more code points than the number of ASCII code points in the input, because of the way the encoding is defined. also the number of code points output cannot exceed the maximum possible value of a punycode_uint, even if the output_length you handed over is bigger than that. so like, chill, it's capped. 🫢
  • punycode_uint [] output β€” an array of code points, same vibe as the input argument of punycode_encode() (see above, go look, i'll wait πŸ’œ).
  • unsigned char [] case_flags β€” either a NULL pointer (if you, the caller, don't need the flags β€” valid, we respect it) or an array of boolean values running parallel to the output array. nonzero (true, flagged) is a lil hint that the corresponding Unicode character should be forced to uppercase by the caller, if possible. zero (false, unflagged) is a hint to force it to lowercase, if possible. and the ASCII code points (0..7F) are already output in the proper case, but their flags get set appropriately anyway so that applying the flags would be harmless. thoughtful queen behavior. πŸ’…

πŸ’– DESCRIPTION πŸ’–

so what does she actually DO? she converts Punycode to a sequence of code points (which we're presuming are Unicode code points). that's the whole job. periodt. ✨

Return value: the return value can be any of the Punycode_status values defined above. and listen carefully bestie β€” if it's not PUNYCODE_SUCCESS, then output_length, output, and case_flags might contain garbage. like actual trash. don't read them. don't trust them. don't look at them. πŸ™ˆ


😭 REPORTING BUGS 😭

found a bug? not the vibe, but we wanna know:


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. (iconic of them honestly, we love a permissive license 🫢)


🌈 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/

go read it, iykyk. πŸ“š


and that's the whole page bestie!! this was libidn version 1.44, page punycode_decode(3) β€” ty for coming to my ted talk, go decode some punycode, mwah πŸ’‹πŸ’–βœ¨

πŸ“¦ where this page comes from