2 3448adb0 2022-11-02 op .Dd ${MAN_DATE}
3 3448adb0 2022-11-02 op .Dt GRAPHEME_IS_CHARACTER_BREAK 3
4 3448adb0 2022-11-02 op .Os suckless.org
6 3448adb0 2022-11-02 op .Nm grapheme_is_character_break
7 3448adb0 2022-11-02 op .Nd test for a grapheme cluster break between two codepoints
11 3448adb0 2022-11-02 op .Fn grapheme_is_character_break "uint_least32_t cp1" "uint_least32_t cp2" "uint_least16_t *state"
12 3448adb0 2022-11-02 op .Sh DESCRIPTION
14 3448adb0 2022-11-02 op .Fn grapheme_is_character_break
15 3448adb0 2022-11-02 op function determines if there is a grapheme cluster break (see
16 3448adb0 2022-11-02 op .Xr libgrapheme 7 )
17 3448adb0 2022-11-02 op between the two codepoints
21 3448adb0 2022-11-02 op By specification this decision depends on a
23 3448adb0 2022-11-02 op that can at most be completely reset after detecting a break and must
24 3448adb0 2022-11-02 op be reset every time one deviates from sequential processing.
30 3448adb0 2022-11-02 op .Fn grapheme_is_character_break
31 3448adb0 2022-11-02 op behaves as if it was called with a fully reset state.
32 3448adb0 2022-11-02 op .Sh RETURN VALUES
34 3448adb0 2022-11-02 op .Fn grapheme_is_character_break
35 3448adb0 2022-11-02 op function returns
37 3448adb0 2022-11-02 op if there is a grapheme cluster break between the codepoints
43 3448adb0 2022-11-02 op if there is not.
46 3448adb0 2022-11-02 op /* cc (-static) -o example example.c -lgrapheme */
47 3448adb0 2022-11-02 op #include <grapheme.h>
48 3448adb0 2022-11-02 op #include <stdint.h>
49 3448adb0 2022-11-02 op #include <stdio.h>
50 3448adb0 2022-11-02 op #include <stdlib.h>
55 3448adb0 2022-11-02 op uint_least16_t state = 0;
56 3448adb0 2022-11-02 op uint_least32_t s1[] = ..., s2[] = ...; /* two input arrays */
59 3448adb0 2022-11-02 op for (i = 0; i + 1 < sizeof(s1) / sizeof(*s1); i++) {
60 3448adb0 2022-11-02 op if (grapheme_is_character_break(s[i], s[i + 1], &state)) {
61 3448adb0 2022-11-02 op printf("break in s1 at offset %zu\n", i);
64 3448adb0 2022-11-02 op memset(&state, 0, sizeof(state)); /* reset state */
65 3448adb0 2022-11-02 op for (i = 0; i + 1 < sizeof(s2) / sizeof(*s2); i++) {
66 3448adb0 2022-11-02 op if (grapheme_is_character_break(s[i], s[i + 1], &state)) {
67 3448adb0 2022-11-02 op printf("break in s2 at offset %zu\n", i);
75 3448adb0 2022-11-02 op .Xr grapheme_next_character_break 3 ,
76 3448adb0 2022-11-02 op .Xr grapheme_next_character_break_utf8 3 ,
77 3448adb0 2022-11-02 op .Xr libgrapheme 7
79 3448adb0 2022-11-02 op .Fn grapheme_is_character_break
80 3448adb0 2022-11-02 op is compliant with the Unicode ${UNICODE_VERSION} specification.
82 3448adb0 2022-11-02 op .An Laslo Hunhold Aq Mt dev@frign.de