libgrapheme

grapheme cluster utility library
git clone git://git.suckless.org/libgrapheme
Log | Files | Refs | LICENSE

grapheme_len.3 (804B)


      1 .Dd 2020-03-26
      2 .Dt GRAPHEME_LEN 3
      3 .Os suckless.org
      4 .Sh NAME
      5 .Nm grapheme_len
      6 .Nd determine grapheme cluster length
      7 .Sh SYNOPSIS
      8 .In grapheme.h
      9 .Ft size_t
     10 .Fn grapheme_len "const char *"
     11 .Sh DESCRIPTION
     12 .Nm
     13 returns the length (in bytes) of the grapheme cluster beginning at
     14 the provided char-address.
     15 .Sh EXAMPLES
     16 .Bd -literal
     17 /* cc (-static) -o example example.c -lgrapheme */
     18 #include <grapheme.h>
     19 #include <stdio.h>
     20 
     21 int
     22 main(void)
     23 {
     24 	char *s = "Tëst 👨\\u200d👩\\u200d👦 🇺🇸 नी நி!";
     25 	size_t len;
     26 
     27 	/* print each grapheme cluster with accompanying byte-length */
     28 	while (*s != '\\0') {
     29 		len = grapheme_len(s);
     30 		printf("%2zu bytes | %.*s\\n", len, (int)len, s, len);
     31 		s += len;
     32 	}
     33 
     34 	return 0;
     35 }
     36 .Ed
     37 .Sh SEE ALSO
     38 .Xr libgrapheme 7
     39 .Sh AUTHORS
     40 .An Laslo Hunhold Aq Mt dev@frign.de