stringprep_utf8_to_ucs4(3)
π stringprep_utf8_to_ucs4 β the libidn glow-up page π
okay so bestie, we're in section 3 of the libidn manual, and today's main character is stringprep_utf8_to_ucs4, an API function that converts your cute little UTF-8 bytes into a big chunky 32-bit UCS-4 situation. no cap, it's giving "encoding translator but make it β¨fixed widthβ¨".
β¨ SYNOPSIS β¨
#include <stringprep.h>
uint32_t * stringprep_utf8_to_ucs4(const char * str, ssize_t len, size_t
* items_written);
like, that's the whole vibe. one function, three args, infinite possibilities π¦
π ARGUMENTS π
const char * strβ a UTF-8 encoded string. literally the thing you're converting, the star of the show πssize_t lenβ the maximum length ofstrto use. and here's the tea: iflen < 0, then the string is nul-terminated. so negativelenmeans "just keep going till you hit the nul", iconic behaviour honestly πsize_t * items_writtenβ the location to store the number of characters in the result, orNULL. so you can passNULLif you don't care, no pressure, live your truth πΈ
π DESCRIPTION π
Convert a string from UTF-8 to a 32-bit fixed width representation as UCS-4. that's the whole job. it takes your variable-width UTF-8 and stretches it out into nice even 32-bit chunks, one character per slot, so it's way easier to index and iterate over. so satisfying π§
and here's the important glow-up note: the function now performs error checking to verify that the input is valid UTF-8. key word being now β before, it was documented to not do error checking. so if you were out here relying on it just vibing through garbage input, that era is over bestie π
Return value: a pointer to a newly allocated UCS-4 string. β οΈ and this part is not a drill β this value must be deallocated by the caller. it's yours now. you asked for it, you free it. no ghosting the allocator, that's rude and also a memory leak π
π«Ά REPORTING BUGS π«Ά
found a bug? spill the tea, don't sit on it:
- Report bugs to <help-libidn@gnu.org>.
- General guidelines for reporting bugs: https://www.gnu.org/gethelp/
- GNU Libidn home page: https://www.gnu.org/software/libidn/
π COPYRIGHT π
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, bestie π)
π 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, the Texinfo manual is where the deep lore lives πβ¨
π this page came to you from libidn 1.44 β yeah that's the version, that's the source, that's the whole footer moment. stay encoded, stay valid, and don't forget to free() π
πΈπ¦
π¦ where this page comes from
- arch rolling: libidn 1.44-1 Β· GPL3 AND LGPL
- epel 10: libidn-devel 1.44-1.el10_3 Β· (LGPL-3.0-or-later OR GPL-2.0-or-later) AND GPL-3.0-or-later AND GFDL-1.3-or-later
- fedora 43: libidn-devel 1.44-1.fc43 Β· (LGPL-3.0-or-later OR GPL-2.0-or-later) AND GPL-3.0-or-later AND GFDL-1.3-or-later
- fedora 43: libidn-devel 1.44-1.fc43 Β· (LGPL-3.0-or-later OR GPL-2.0-or-later) AND GPL-3.0-or-later AND GFDL-1.3-or-later
- fedora 44: libidn-devel 1.44-1.fc44 Β· (LGPL-3.0-or-later OR GPL-2.0-or-later) AND GPL-3.0-or-later AND GFDL-1.3-or-later
- fedora 44: libidn-devel 1.44-1.fc44 Β· (LGPL-3.0-or-later OR GPL-2.0-or-later) AND GPL-3.0-or-later AND GFDL-1.3-or-later
- ubuntu stonking: libidn-dev 1.44-1 Β· 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