libgrapheme

unicode string library
git clone git://git.suckless.org/libgrapheme
Log | Files | Refs | README | LICENSE

grapheme_is_character_break.sh (1949B)


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