grapheme_is_character_break.3 - libgrapheme - unicode string library
(HTM) git clone git://git.suckless.org/libgrapheme
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
grapheme_is_character_break.3 (1925B)
---
1 .Dd 2022-08-26
2 .Dt GRAPHEME_IS_CHARACTER_BREAK 3
3 .Os suckless.org
4 .Sh NAME
5 .Nm grapheme_is_character_break
6 .Nd test for a grapheme cluster break between two codepoints
7 .Sh SYNOPSIS
8 .In grapheme.h
9 .Ft size_t
10 .Fn grapheme_is_character_break "uint_least32_t cp1" "uint_least32_t cp2" "GRAPHEME_STATE *state"
11 .Sh DESCRIPTION
12 The
13 .Fn grapheme_is_character_break
14 function determines if there is a grapheme cluster break (see
15 .Xr libgrapheme 7 )
16 between the two codepoints
17 .Va cp1
18 and
19 .Va cp2 .
20 By specification this decision depends on a
21 .Va state
22 that can at most be completely reset after detecting a break and must
23 be reset every time one deviates from sequential processing.
24 .Pp
25 If
26 .Va state
27 is
28 .Dv NULL
29 .Fn grapheme_is_character_break
30 behaves as if it was called with a fully reset state.
31 .Sh RETURN VALUES
32 The
33 .Fn grapheme_is_character_break
34 function returns
35 .Va true
36 if there is a grapheme cluster break between the codepoints
37 .Va cp1
38 and
39 .Va cp2
40 and
41 .Va false
42 if there is not.
43 .Sh EXAMPLES
44 .Bd -literal
45 /* cc (-static) -o example example.c -lgrapheme */
46 #include <grapheme.h>
47 #include <stdint.h>
48 #include <stdio.h>
49 #include <stdlib.h>
50
51 int
52 main(void)
53 {
54 GRAPHEME_STATE state = { 0 };
55 uint_least32_t s1[] = ..., s2[] = ...; /* two input arrays */
56 size_t i;
57
58 for (i = 0; i + 1 < sizeof(s1) / sizeof(*s1); i++) {
59 if (grapheme_is_character_break(s[i], s[i + 1], &state)) {
60 printf("break in s1 at offset %zu\n", i);
61 }
62 }
63 memset(&state, 0, sizeof(state)); /* reset state */
64 for (i = 0; i + 1 < sizeof(s2) / sizeof(*s2); i++) {
65 if (grapheme_is_character_break(s[i], s[i + 1], &state)) {
66 printf("break in s2 at offset %zu\n", i);
67 }
68 }
69
70 return 0;
71 }
72 .Ed
73 .Sh SEE ALSO
74 .Xr grapheme_next_character_break 3 ,
75 .Xr grapheme_next_character_break_utf8 3 ,
76 .Xr libgrapheme 7
77 .Sh STANDARDS
78 .Fn grapheme_is_character_break
79 is compliant with the Unicode 14.0.0 specification.
80 .Sh AUTHORS
81 .An Laslo Hunhold Aq Mt dev@frign.de