punycode_encode(3)

πŸ’– punycode_encode(3) πŸ’–

okay bestie, gather round, we're doing a libidn moment β€” this one's punycode_encode, and she is literally the girl who turns your code points into Punycode. no cap. ✨


✨ NAME ✨

punycode_encode β€” API function πŸ’…


🌸 SYNOPSIS 🌸

#include <punycode.h>

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

πŸŽ€ ARGUMENTS πŸŽ€

  • size_t input_length β€” the number of code points hanging out in the input array, and also the number of flags in the case_flags array. same number, two jobs, multitasking queen πŸ‘‘
  • const punycode_uint [] input β€” an array of code points. they're presumed to be Unicode code points, but ngl that is not strictly REQUIRED. important distinction, bestie: this array holds code points, not code units. UTF-16 uses code units D800 through DFFF to refer to code points 10000..10FFFF. the code points D800..DFFF do not occur in any valid Unicode string. and the code points that can occur in Unicode strings (0..D7FF and E000..10FFFF) are also called Unicode scalar values. so that's the lore πŸ¦‹
  • const unsigned char [] case_flags β€” either a NULL pointer or an array of boolean values that runs parallel to the input array. nonzero (true, flagged) suggests the corresponding Unicode character get forced to uppercase after being decoded (if possible), and zero (false, unflagged) suggests it get forced to lowercase (if possible). ASCII code points (0..7F) are encoded literally, except ASCII letters get forced uppercase or lowercase according to the corresponding case flags. if case_flags is a NULL pointer then ASCII letters are left exactly as they are, and other code points are treated as unflagged. so basically the flags are the outfit change, and NULL is "we're going out in what we're wearing" πŸ’€
  • size_t * output_length β€” the caller passes in the maximum number of ASCII code points it can receive. on successful return it will contain the number of ASCII code points actually output. it's giving "capacity in, reality out" 🌈
  • char [] output β€” an array of ASCII code points. it is *not* null-terminated; it will contain zeros if and only if the input contains zeros. (of course the caller can leave room for a terminator and add one if needed β€” thoughtful king behavior 🫢)

πŸ”₯ DESCRIPTION πŸ”₯

Converts a sequence of code points (presumed to be Unicode code points) to Punycode. that's the whole gig. she eats code points, she serves Punycode πŸ’…

Return value: the return value can be any of the Punycode_status values defined above except PUNYCODE_BAD_INPUT.

🚨 bestie listen β€” if it's not PUNYCODE_SUCCESS, then output_size and output might contain garbage. literally garbage. do not trust them. do not pass go. 😭

πŸ’œ DESCRIPTION πŸ’œ

(okay so the manual says it twice and honestly? she said it twice because it matters, periodt)

Converts a sequence of code points (presumed to be Unicode code points) to Punycode.

Return value: the return value can be any of the Punycode_status values defined above except PUNYCODE_BAD_INPUT. If not PUNYCODE_SUCCESS, then output_size and output might contain garbage.


πŸ› REPORTING BUGS πŸ›


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, legally speaking πŸ’–


πŸ¦‹ 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/

and that's the whole page, bestie!! this is from libidn, version 1.44, and yeah the footer is just punycode_encode(3) again because the manpage header and footer are doing their little matching-couple thing 🌸✨ mwah, go encode something cute πŸ’…πŸ’–

πŸ“¦ where this page comes from