Blame


1 3448adb0 2022-11-02 op cat << EOF
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
5 3448adb0 2022-11-02 op .Sh NAME
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
8 3448adb0 2022-11-02 op .Sh SYNOPSIS
9 3448adb0 2022-11-02 op .In grapheme.h
10 3448adb0 2022-11-02 op .Ft size_t
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
13 3448adb0 2022-11-02 op The
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
18 3448adb0 2022-11-02 op .Va cp1
19 3448adb0 2022-11-02 op and
20 3448adb0 2022-11-02 op .Va cp2 .
21 3448adb0 2022-11-02 op By specification this decision depends on a
22 3448adb0 2022-11-02 op .Va state
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.
25 3448adb0 2022-11-02 op .Pp
26 3448adb0 2022-11-02 op If
27 3448adb0 2022-11-02 op .Va state
28 3448adb0 2022-11-02 op is
29 3448adb0 2022-11-02 op .Dv NULL
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
33 3448adb0 2022-11-02 op The
34 3448adb0 2022-11-02 op .Fn grapheme_is_character_break
35 3448adb0 2022-11-02 op function returns
36 3448adb0 2022-11-02 op .Va true
37 3448adb0 2022-11-02 op if there is a grapheme cluster break between the codepoints
38 3448adb0 2022-11-02 op .Va cp1
39 3448adb0 2022-11-02 op and
40 3448adb0 2022-11-02 op .Va cp2
41 3448adb0 2022-11-02 op and
42 3448adb0 2022-11-02 op .Va false
43 3448adb0 2022-11-02 op if there is not.
44 3448adb0 2022-11-02 op .Sh EXAMPLES
45 3448adb0 2022-11-02 op .Bd -literal
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>
51 3448adb0 2022-11-02 op
52 3448adb0 2022-11-02 op int
53 3448adb0 2022-11-02 op main(void)
54 3448adb0 2022-11-02 op {
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 */
57 3448adb0 2022-11-02 op size_t i;
58 3448adb0 2022-11-02 op
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);
62 3448adb0 2022-11-02 op }
63 3448adb0 2022-11-02 op }
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);
68 3448adb0 2022-11-02 op }
69 3448adb0 2022-11-02 op }
70 3448adb0 2022-11-02 op
71 3448adb0 2022-11-02 op return 0;
72 3448adb0 2022-11-02 op }
73 3448adb0 2022-11-02 op .Ed
74 3448adb0 2022-11-02 op .Sh SEE ALSO
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
78 3448adb0 2022-11-02 op .Sh STANDARDS
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.
81 3448adb0 2022-11-02 op .Sh AUTHORS
82 3448adb0 2022-11-02 op .An Laslo Hunhold Aq Mt dev@frign.de
83 3448adb0 2022-11-02 op EOF