UNICODE::LINEBREAK(3)
π UNICODE::LINEBREAK(3) π
okay bestie, pull up a chair, we're doing unicode::linebreak from the Courier Unicode Library today and honestly?? it's giving "buffer girlboss" energy. it's all about unicode line-breaking rules π
and it is lowkey iconic.
β¨ NAME β¨
unicode::linebreak_callback_base, unicode::linebreak_callback_save_buf, unicode::linebreakc_callback_base, unicode::linebreak_iter, unicode::linebreakc_iter β unicode line-breaking rules π
πΈ SYNOPSIS πΈ
#include <courier-unicode.h>
class linebreak : public unicode::linebreak_callback_base {
public:
using unicode::linebreak_callback_base::operator<<;
using unicode::linebreak_callback_base::operator();
int callback(int linebreak_code)
{
// ...
}
};
char32_t c;
std::u32string buf;
linebreak compute_linebreak;
compute_linebreak.set_opts(UNICODE_LB_OPT_SYBREAK);
compute_linebreak << c;
compute_linebreak(buf);
compute_linebreak(buf.begin(), buf.end());
compute_linebreak.finish();
// ...
unicode::linebreak_callback_save_buf linebreaks;
std::list<int> lb=linebreaks.lb_buf;
class linebreakc : public unicode::linebreakc_callback_base {
public:
using unicode::linebreak_callback_base::operator<<;
using unicode::linebreak_callback_base::operator();
int callback(int linebreak_code, char32_t ch)
{
// ...
}
};
// ...
std::u32string buf;
typedef unicode::linebreak_iter<std::u32string::const_iterator> iter_t;
iter_t beg_iter(buf.begin(), buf.end()), end_iter;
beg_iter.set_opts(UNICODE_LB_OPT_SYBREAK);
std::vector<int> linebreaks;
std::copy(beg_iter, end_iter, std::back_insert_iterator<std::vector<int>>(linebreaks));
// ...
typedef unicode::linebreakc_iter<std::u32string::const_iterator> iter_t;
iter_t beg_iter(buf.begin(), buf.end()), end_iter;
beg_iter.set_opts(UNICODE_LB_OPT_SYBREAK);
std::vector<std::pair<int, char32_t>> linebreaks;
std::copy(beg_iter, end_iter, std::back_insert_iterator<std::vector<int>>(linebreaks));
π¦ DESCRIPTION π¦
so unicode::linebreak_callback_base is a C++ binding for the unicode line-breaking rule implementation described over in unicode_line_break(3). no cap π§
the callback vibe check π
you subclass unicode::linebreak_callback_base and implement callback(), which is virtually inherited from unicode::linebreak_callback_base. that callback() function lowkey receives the output values from the line-breaking algorithm β the UNICODE_LB_MANDATORY, UNICODE_LB_NONE, or the UNICODE_LB_ALLOWED value β and it does that for each unicode character. periodt β¨
callback() should return 0. a non-zero return reports an error, and that error stops the line-breaking algorithm entirely π β so like, don't do that unless you mean it. see unicode_line_break(3) for more info.
the other flavor π
the alternate unicode::linebreakc_callback_base interface uses a virtually inherited callback() that takes two parameters: the line-break code value, and the corresponding unicode character. two for the price of one, we love to see it π
feeding it characters π
the input unicode characters for the line-breaking algorithm come in two ways:
- via the
<<operator, one unicode character at a time π - via the
()operator, where you pass either a container, or a beginning and an ending iterator value for an input sequence of unicode characters β¨
and finish() is the little "that's all folks" β it indicates the end of the unicode character sequence. π
set_opts sets the line-breaking options (peep unicode_lb_set_opts() for more info, iykyk).
saving those breaks πΎ
unicode::linebreak_callback_save_buf is a subclass that implements callback() by saving the linebreak codes into a std::list. bestie is literally just a little hoarder of line breaks, and honestly? valid.
iterator era π
the linebreak_iter template implements an input iterator over ints. the template parameter is an input iterator over unicode chars. the constructor's parameters are a beginning and an ending iterator value for a sequence of char32_t. this constructs the beginning iterator value for a sequence of ints consisting of line-break values (UNICODE_LB_MANDATORY, UNICODE_LB_NONE, or UNICODE_LB_ALLOWED) corresponding to each char32_t in the underlying sequence. and the default constructor creates the ending iterator value for that sequence. π«Ά
the iterator implements a set_opts() method that sets the options for the line-breaking algorithm.
the linebreakc_iter template implements a similar input iterator, with the difference that it ends up iterating over a std::pair of line-breaking values and the corresponding char32_t from the underlying input sequence. so it's like linebreak_iter but it brought a plus-one πβ¨
π SEE ALSO π
courier-unicode(7), unicode_line_break(3).
π AUTHOR π
Sam Varshavchik Author
mwah π that's the whole page bestie, you ate. this was Courier Unicode Library, dated 04/12/2026, and you were reading UNICODE::LINEBREAK(3) β go break some lines 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