UNICODE_WORD_BREAK(3)
π UNICODE_WORD_BREAK(3) β bestie edition π
okay so this is UNICODE_WORD_BREAK(3) from the Courier Unicode Library, and it's literally the whole "where do words end" saga. pull up a chair π«Ά
β¨ NAME β¨
unicode_wb_init, unicode_wb_next, unicode_wb_next_cnt, unicode_wb_end, unicode_wbscan_init, unicode_wbscan_next, unicode_wbscan_end, unicode_word_break β calculate word breaks π¦
β¨ SYNOPSIS β¨
#include <courier-unicode.h>
unicode_wb_info_t unicode_wb_init(int (*cb_func)(int, void *),
void *cb_arg);
int unicode_wb_next(unicode_wb_info_t wb, char32_t c);
int unicode_wb_next_cnt(unicode_wb_info_t wb, const char32_t *cptr,
size_t cnt);
int unicode_wb_end(unicode_wb_info_t wb);
unicode_wbscan_info_t unicode_wbscan_init(void);
int unicode_wbscan_next(unicode_wbscan_info_t wbs, char32_t c);
size_t unicode_wbscan_end(unicode_wbscan_info_t wbs);
β¨ DESCRIPTION β¨
so these functions are the full unicode word breaking algorithm, no cap. π
call unicode_wb_init() to kick the whole word breaking thing off. first parameter is a callback function, second parameter is an opaque pointer. that callback gets invoked with two parameters: the second one is the same opaque pointer you handed to unicode_wb_init(), and ngl these functions do not interpret that pointer in any way, shape or form. it's just vibing there, untouched. π
unicode_wb_init() hands you back an opaque handle. then you call unicode_wb_next() over and over with that handle plus one unicode character at a time β and that whole sequence of unicode characters is the thing the word breaking algorithm does its math on. unicode_wb_next_cnt() is just the shortcut version: it repeatedly invokes unicode_wb_next() over an array cptr containing cnt unicode characters. efficient queen π
unicode_wb_end() says "that's it, sequence over." and after you call unicode_wb_end(), the word breaking unicode_wb_info_t handle is no longer valid. gone. don't touch it. π
between the unicode_wb_init() call and the unicode_wb_end() call, the callback function gets invoked exactly once for each unicode character you gave to unicode_wb_next() or unicode_wb_next_cnt(). usually each unicode_wb_next() call makes the callback fire right away β but it does not have to be that way, bestie. it's possible that a call to unicode_wb_next() returns without invoking the callback at all, and then some subsequent unicode_wb_next() call (or unicode_wb_end()) fires the callback more than once to catch up. the actual contract is: before unicode_wb_end() returns, the callback has been invoked the exact number of times equal to the number of characters in the unicode sequence defined by all those intervening unicode_wb_next() and unicode_wb_next_cnt() calls β unless an error happens, in which case all bets are off. π
every callback call reports the calculated wordbreaking status of the corresponding character in the sequence. if the parameter to the callback is non-zero, a word break is permitted before that character. a zero value means a word break is prohibited before that character. that's the whole vibe check right there β
the callback should return 0. a non-zero value tells the word breaking algorithm that an error occurred. unicode_wb_next() and unicode_wb_next_cnt() return zero either if they never invoked the callback function, or if every callback call returned zero. a non-zero return from the callback makes unicode_wb_next() and unicode_wb_next_cnt() immediately return that same value, like, instantly, no hesitation. π₯
you must invoke unicode_wb_end() to destroy the word breaking handle β yes, even if unicode_wb_next() and unicode_wb_next_cnt() returned an error indication. also, under totally normal circumstances, unicode_wb_end() can invoke the callback function one or more times. the return value from unicode_wb_end() means the same thing as the return value from unicode_wb_next() and unicode_wb_next_cnt(). but in all cases, once unicode_wb_end() returns, the line breaking handle is no longer valid. periodt. π
πΈ Word scan πΈ
unicode_wbscan_init(), unicode_wbscan_next() and unicode_wbscan_end scan for the next word boundary in a unicode character sequence. π§
unicode_wbscan_init() gets you a handle, then you repeatedly invoke unicode_wbscan_next() to define the unicode character sequence. unicode_wbscan_end() deallocates the handle and returns the number of leading characters in the unicode character sequence up to the first word break. iconic. β¨
a non-0 return value from unicode_wbscan_next() means the word boundary is already known, and any further calls to unicode_wbscan_next() will just be ignored. you still gotta call unicode_wbscan_end() though, because that's how you get the unicode character count. don't forget, bestie π«Ά
β¨ SEE ALSO β¨
TR-29[1]courier-unicode(7)unicode::wordbreak(3)unicode_convert_tocase(3)unicode_line_break(3)unicode_grapheme_break(3)
β¨ AUTHOR β¨
Sam Varshavchik β Author π
β¨ NOTES β¨
and that's the whole page, bestie π this was Courier Unicode Library, dated 04/12/2026, page UNICODE_WORD_BREAK(3) β slay, bye, go break some words ππ
πΈ
π¦ 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