GRAPHEME_IS_CHARACTER_BREAK(3)
okay so bestie, this is grapheme_is_character_break(3), straight outta the Library Functions Manual, and it's here to answer the most main-character question ever: is there a grapheme cluster break between two codepoints? π
β¨
πΈ NAME πΈ
grapheme_is_character_break β test for a grapheme cluster break between two codepoints.
π SYNOPSIS π
#include <grapheme.h>
size_t
grapheme_is_character_break(uint_least32_t cp1, uint_least32_t cp2,
uint_least16_t *state);
π DESCRIPTION π
The grapheme_is_character_break() function figures out if thereβs a grapheme cluster break (peep libgrapheme(7) for the lore) between the two codepoints cp1 and cp2. π¦
By specification, this decision depends on a state that can at most be completely reset after detecting a break β and it must be reset every single time one deviates from sequential processing. no cap, the state is lowkey doing a lot here. π
If state is NULL, grapheme_is_character_break() behaves as if it was called with a fully reset state. periodt. π
π₯ RETURN VALUES π₯
The grapheme_is_character_break() function returns true if there is a grapheme cluster break between the codepoints cp1 and cp2, and false if there is not. it's giving simple and iconic. π
π EXAMPLES π
hereβs the example, copied verbatim, bestie β do not come for the formatting, just vibe with it:
/* cc (-static) -o example example.c -lgrapheme */
#include <grapheme.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
int
main(void)
{
uint_least16_t state = 0;
uint_least32_t s1[] = ..., s2[] = ...; /* two input arrays */
size_t i;
for (i = 0; i + 1 < sizeof(s1) / sizeof(*s1); i++) {
if (grapheme_is_character_break(s[i], s[i + 1], &state)) {
printf("break in s1 at offset %zu0, i);
}
}
memset(&state, 0, sizeof(state)); /* reset state */
for (i = 0; i + 1 < sizeof(s2) / sizeof(*s2); i++) {
if (grapheme_is_character_break(s[i], s[i + 1], &state)) {
printf("break in s2 at offset %zu0, i);
}
}
return 0;
}
π§ SEE ALSO π§
β STANDARDS β
grapheme_is_character_break() is compliant with the Unicode 17.0.0 specification. slay. π
π«Ά AUTHORS π«Ά
Laslo Hunhold <dev@frign.de>
this iconic page comes from suckless.org, dated 2022-10-06, and itβs GRAPHEME_IS_CHARACTER_BREAK(3) β mwah, bye bestie ππ
π¦ where this page comes from
- nixos 26.05: libgrapheme 3.0.0
- nixpkgs unstable: libgrapheme 3.0.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms