index.md (1982B)
1 GRAPHEME\_IS\_CHARACTER\_BREAK(3) - Library Functions Manual 2 3 # NAME 4 5 **grapheme\_is\_character\_break** - test for a grapheme cluster break between two codepoints 6 7 # SYNOPSIS 8 9 **#include <grapheme.h>** 10 11 *size\_t* 12 **grapheme\_is\_character\_break**(*uint\_least32\_t cp1*, *uint\_least32\_t cp2*, *uint\_least16\_t \*state*); 13 14 # DESCRIPTION 15 16 The 17 **grapheme\_is\_character\_break**() 18 function determines if there is a grapheme cluster break (see 19 libgrapheme(7)) 20 between the two codepoints 21 *cp1* 22 and 23 *cp2*. 24 By specification this decision depends on a 25 *state* 26 that can at most be completely reset after detecting a break and must 27 be reset every time one deviates from sequential processing. 28 29 If 30 *state* 31 is 32 `NULL` 33 **grapheme\_is\_character\_break**() 34 behaves as if it was called with a fully reset state. 35 36 # RETURN VALUES 37 38 The 39 **grapheme\_is\_character\_break**() 40 function returns 41 *true* 42 if there is a grapheme cluster break between the codepoints 43 *cp1* 44 and 45 *cp2* 46 and 47 *false* 48 if there is not. 49 50 # EXAMPLES 51 52 /* cc (-static) -o example example.c -lgrapheme */ 53 #include <grapheme.h> 54 #include <stdint.h> 55 #include <stdio.h> 56 #include <stdlib.h> 57 58 int 59 main(void) 60 { 61 uint_least16_t state = 0; 62 uint_least32_t s1[] = ..., s2[] = ...; /* two input arrays */ 63 size_t i; 64 65 for (i = 0; i + 1 < sizeof(s1) / sizeof(*s1); i++) { 66 if (grapheme_is_character_break(s[i], s[i + 1], &state)) { 67 printf("break in s1 at offset %zu0, i); 68 } 69 } 70 memset(&state, 0, sizeof(state)); /* reset state */ 71 for (i = 0; i + 1 < sizeof(s2) / sizeof(*s2); i++) { 72 if (grapheme_is_character_break(s[i], s[i + 1], &state)) { 73 printf("break in s2 at offset %zu0, i); 74 } 75 } 76 77 return 0; 78 } 79 80 # SEE ALSO 81 82 grapheme\_next\_character\_break(3), 83 grapheme\_next\_character\_break\_utf8(3), 84 libgrapheme(7) 85 86 # STANDARDS 87 88 **grapheme\_is\_character\_break**() 89 is compliant with the Unicode 15.0.0 specification. 90 91 # AUTHORS 92 93 Laslo Hunhold ([dev@frign.de](mailto:dev@frign.de)) 94 95 suckless.org - 2022-10-06