GRAPHEME_IS_CHARACTER_BREAK(3)

πŸ“¦ version 3.0.0, in nixos 26.05, nixpkgs unstable

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