UNICODE::CANONICAL(3)

πŸ’– UNICODE::CANONICAL πŸ’–

okay so bestie, you know the file is literally called UNICODE::CANONICAL and it lives in the Courier Unicode Library β€” that's the vibe, that's the whole setup. sit down, grab a strawberry πŸ“, we're doing Unicode normalization.


✨ NAME ✨

unicode::canonical, unicode::decompose, unicode::decompose_default_reallocate, unicode::compose, unicode::compose_default_callback β€” unicode canonical normalization and denormalization πŸ¦‹

like… it breaks text apart, it puts text back together. canonically. no cap.


🌸 SYNOPSIS 🌸

#include <courier-unicode.h>

constexpr int decompose_flag_qc=UNICODE_DECOMPOSE_FLAG_QC;
constexpr int decompose_flag_compat=UNICODE_DECOMPOSE_FLAG_COMPAT;

constexpr int compose_flag_removeunused=UNICODE_COMPOSE_FLAG_REMOVEUNUSED;
constexpr int compose_flag_oneshot=UNICODE_COMPOSE_FLAG_ONESHOT;

void decompose_default_reallocate(std::u32string &string,
                                  const std::vector<std::tuple<size_t, size_t>> &list);

void decompose(std::u32string &string, int flags=0,
               const std::function<void (std::u32string &,
               const std::vector<std::tuple<size_t, size_t>>)>
               &reallocate=decompose_default_reallocate);

void compose_default_callback(unicode_composition_t &compositions);

void compose(std::u32string &string, int flags=0,
             const std::function<void (unicode_composition_t &)> &cb=compose_default_reallocate);

yes, that last default really do be compose_default_reallocate in the compose() line πŸ’… we don't question the source material, we just copy it character for character.


πŸ‘‘ DESCRIPTION πŸ‘‘

these functions are the C++ interface for the Unicode Canonical Decomposition and Composition[1]. so like, if you want the lore on the actual underlying C library, go read unicode_canonical(3). but here's the C++-specific tea β˜•:

  • the C++ decomposition reallocate callback gets one single vector of offset and size tuples instead of two separate arrays or vectors. iconic behavior, honestly. and unicode::decompose_default_reallocate() is the C++ version of the default reallocate callback β€” it also receives that same tuple vector parameter. the C++ interface uses std::u32strings to represent Unicode text strings, and unicode::decompose_default_reallocate() resizes it. 🧚

and like the C callback, the C++ one gets called 0 or more times. zero! or more! both are valid and it's fine, promise.

  • unicode::compose() handles initializing, applying, and de-initialization of the unicode_composition_t object, for decomposition. the callback receives a reference to the unicode_composition_t object, and bestie, the callback should not modify it in any way. don't touch. hands off. it's giving "look, don't touch" πŸ™ˆ

🌈 SEE ALSO 🌈


🫢 AUTHOR 🫢

Sam Varshavchik Author πŸ’œ


⭐ NOTES ⭐

  1. Unicode Canonical Decomposition and Composition https://www.unicode.org/reports/tr15/tr15-57.html

and that's the whole page, bestie!! brought to you by the Courier Unicode Library, dated 04/12/2026 πŸŽ€ go forth and normalize canonically, you absolute main character πŸ‘‘βœ¨

πŸ“¦ where this page comes from