UNICODE_LINE_BREAK(3)
β¨ NAME β¨
unicode_line_break, unicode_lb_init, unicode_lb_set_opts, unicode_lb_next, unicode_lb_next_cnt, unicode_lb_end, unicode_lbc_init, unicode_lbc_set_opts, unicode_lbc_next, unicode_lbc_next_cnt, unicode_lbc_end β calculate mandatory or allowed line breaks π
(also this is the Courier Unicode Library man page, iiiin case you were wondering, bestie π«Ά)
πΈ SYNOPSIS πΈ
#include <courier-unicode.h>
unicode_lb_info_t unicode_lb_init(int (*cb_func)(int, void *),
void *cb_arg);
void unicode_lb_set_opts(unicode_lb_info_t lb, int opts);
int unicode_lb_next(unicode_lb_info_t lb, char32_t c);
int unicode_lb_next_cnt(unicode_lb_info_t lb, const char32_t *cptr,
size_t cnt);
int unicode_lb_end(unicode_lb_info_t lb);
unicode_lbc_info_t
unicode_lbc_init(int (*cb_func)(int, char32_t, void *),
void *cb_arg);
void unicode_lbc_set_opts(unicode_lbc_info_t lb, int opts);
int unicode_lbc_next(unicode_lb_info_t lb, char32_t c);
int unicode_lbc_next_cnt(unicode_lb_info_t lb, const char32_t *cptr,
size_t cnt);
int unicode_lbc_end(unicode_lb_info_t lb);
π¦ DESCRIPTION π¦
okay so. these functions are literally the unicode line breaking algorithm, the whole entire thing, and they eat it for breakfast π₯
Start it up with unicode_lb_init(). First parameter is a callback function. Second parameter is an opaque pointer. That callback gets called with two parameters:
- The first one is one of three values:
UNICODE_LB_MANDATORY,UNICODE_LB_NONE, orUNICODE_LB_ALLOWED, all explained below, promise π - The second one is the opaque pointer you handed to
unicode_lb_init(), and these functions will not touch it, interpret it, or do literally anything else with it. it's yours.
unicode_lb_init() hands back an opaque handle. Then you call unicode_lb_next() over and over, passing the handle plus, like, one unicode character at a time, and that defines the unicode character sequence that the line breaking algorithm is doing its little calculations over. And unicode_lb_next_cnt() is just the shortcut version: it does unicode_lb_next() repeatedly over an array cptr that holds cnt unicode characters. queen behavior π
unicode_lb_end() is how you say "the unicode character sequence ends HERE." And after you call unicode_lb_end(), the unicode_lb_info_t line breaking handle is no longer valid. gone. done. don't touch it.
In between unicode_lb_init() and unicode_lb_end(), the callback function gets invoked exactly once per unicode character you gave to unicode_lb_next() or unicode_lb_next_cnt(). Usually each unicode_lb_next() call means the callback fires right away, but ngl it does not have to. It's fully possible that a unicode_lb_next() call returns without invoking the callback at all, and then some later unicode_lb_next() (or unicode_lb_end()) invokes the callback more than once to catch up. The way the contract works: before unicode_lb_end() returns, the callback gets invoked the exact number of times equal to the number of characters in the unicode sequence defined by all the unicode_lb_next() and unicode_lb_next_cnt() calls in between β unless an error happens, obviously π
Every callback call reports the calculated line breaking status of its corresponding character in the sequence:
UNICODE_LB_MANDATORYβ a line break is MANDATORY before the corresponding character. like, you MUST break here.UNICODE_LB_NONEβ a line break is PROHIBITED before the corresponding character. absolutely not. no.UNICODE_LB_ALLOWEDβ a line break is OPTIONAL before the corresponding character. your call bestie π
The callback function should return 0. A non-zero value is you telling the line breaking algorithm that an error has occurred. unicode_lb_next() and unicode_lb_next_cnt() return zero either if they never invoked the callback function, or if every callback call returned zero. If the callback returns non-zero, unicode_lb_next() and unicode_lb_next_cnt() immediately return that same value. instant. no notes.
You must call unicode_lb_end() to destroy the line breaking handle even if unicode_lb_next() and unicode_lb_next_cnt() returned an error indication. And also, under totally normal circumstances, unicode_lb_end() might invoke the callback function one or more times. The return value from unicode_lb_end() means the same thing as it does from unicode_lb_next() and unicode_lb_next_cnt(); but in all cases, once unicode_lb_end() returns, the line breaking handle is no longer valid. periodt π
π Alternative callback function π
unicode_lbc_init(), unicode_lbc_next(), unicode_lbc_next_cnt(), unicode_lbc_end() are the alternative functions that implement the exact same algorithm. The only difference: the callback function receives an extra parameter β the unicode character value that the line breaking status applies to β passed through from the input unicode character sequence. that's it. that's the whole diff. iconic. β¨
π Options π
unicode_lb_set_opts() and unicode_lbc_set_opts() turn on non-default options for the line breaking algorithm. These functions must be called immediately after unicode_lb_init() or unicode_lbc_init(), and before any other function. Like, immediately. Right after. Don't be late.
opts is a bitmask and it can contain these values:
UNICODE_LB_OPT_PRBREAKβ enables a modified LB24 rule. This stops plus signs, like in βC++β, from breaking. This flag adds the following rules to the LB24 rule:
PR x PR
AL x PR
ID x PR
UNICODE_LB_OPT_SYBREAKβ tailored breaking rules for the β/β character. This prevents breaking after the β/β character (think URLs, bestie π¦); including an exception to the βx SYβ rule in LB13. This flag adds the following rules to the LB24 rule:
SY x EX
SY x AL
SY x ID
SP Γ· SY, which takes precedence over "x SY".
UNICODE_LB_OPT_DASHWJβ this flag reclassifiesU+2013andU+2014as classWJ, prohibiting breaks before and after the m-dash and the n-dash unicode characters. no dash drama on your watch π
π SEE ALSO π
courier-unicode(7), unicode::linebreak(3), TR-14[1]
π AUTHOR π
Sam Varshavchik Author
β NOTES β
and that's the whole page, bestie π«Ά this was Courier Unicode Library, dated 04/12/2026, and it lives in the manual as UNICODE_LINE_BREAK(3) β go forth and break lines correctly, ily πβ¨π
π¦ 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