UNICODE_GRAPHEME_BRE(3)
π UNICODE_GRAPHEME_BRE(3) π
okay bestie, so this is a page from the Courier Unicode Library and it's literally all about unicode grapheme cluster boundary rules β aka "where do I actually cut this text so I don't slice a letter in half" energy. no cap, this is the good stuff. β¨
πΈ NAME πΈ
unicode_grapheme_break, unicode_grapheme_break_init, unicode_grapheme_break_next, unicode_grapheme_break_deinit β the unicode grapheme cluster boundary rules, periodt.
π SYNOPSIS π
#include <courier-unicode.h>
unicode_grapheme_break_info_t unicode_grapheme_break_init(void);
int unicode_grapheme_next(unicode_grapheme_break_info_t handle,
char32_t c);
void unicode_grapheme_deinit(unicode_grapheme_break_info_t handle);
int unicode_grapheme_break(char32_t a, char32_t b);
π¦ DESCRIPTION π¦
These functions implement the unicode grapheme cluster breaking algorithm. it's giving β¨text segmentationβ¨ and we're obsessed.
Call unicode_grapheme_break_init() to initialize the grapheme cluster breaking algorithm. unicode_grapheme_break_init() hands you back an opaque handle β like a little backstage pass ποΈ, you don't peek inside it, you just hold it and pass it around.
Then every time you call unicode_grapheme_break_next(), you give it that handle plus the next character. unicode_grapheme_break_next() returns a non-0 value if there's a grapheme break before the character, inside a sequence of Unicode characters. so non-0 means "cut here bestie βοΈ", zero means "nah, this char is glued to the last one".
unicode_grapheme_break_deinit() releases all the resources used by the grapheme breaking handle, and the unicode_grapheme_break_info_t handle is no longer valid after this call. like, it's done, it's retired, do NOT text it back π one and done.
π«Ά tiny lil heads-up that lowkey matters: the first call to unicode_grapheme_break_next() always returns non-0, as per the GB1 rule. yes always. that's just the rule, iykyk.
unicode_grapheme_break() is the simplified little interface β it returns non-zero if there is a grapheme break between two unicode characters a and b. it's the lazy-girl route and honestly? iconic.
It is equivalent to calling unicode_grapheme_break_init(), followed by two calls to unicode_grapheme_break_next(), and finally unicode_grapheme_break_deinit(), then returning the result of the second call to unicode_grapheme_break_next(). so if you ever wondered "what is this function doing under the hood", that's the whole tea ββ¨
π SEE ALSO π
π«Ά AUTHOR π«Ά
Sam Varshavchik Author
π NOTES π
and that's the whole page bestie, you ate it π this was the Courier Unicode Library doc, version dated 04/12/2026, and we are officially caught up on our grapheme cluster breaking rules. main character Unicode knowledge, fr fr. go break some clusters responsibly πππ
π¦ where this page comes from
- nixpkgs unstable: courier-unicode 2.6.0
- ubuntu stonking: libcourier-unicode-dev 2.6.0-2ubuntu1 Β· GPL-3.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms