X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Funigbrk.in.h;h=5310d6fc6fe7e5131b3fa411769cbbafec35f821;hb=221d8efe25aa7f053d3a2d2dedb4f98886500784;hp=c6056b37600872678691ed07c8c66bed451922bd;hpb=82c48f3071bf6bed40b7914fc87732c491b9d548;p=gnulib.git diff --git a/lib/unigbrk.in.h b/lib/unigbrk.in.h index c6056b376..5310d6fc6 100644 --- a/lib/unigbrk.in.h +++ b/lib/unigbrk.in.h @@ -21,6 +21,9 @@ /* Get bool. */ #include +/* Get size_t. */ +#include + #include "unitypes.h" #ifdef __cplusplus @@ -75,6 +78,48 @@ extern int extern bool uc_is_grapheme_cluster_break (ucs4_t a, ucs4_t b); +/* Returns the length (in units) of the first grapheme cluster in the N units + in S. If the return value is N, then extending the string could extend the + length of the grapheme cluster too. Returns 0 only if N is zero. */ +extern size_t + u8_grapheme_len (const uint8_t *s, size_t n); +extern size_t + u16_grapheme_len (const uint16_t *s, size_t n); +extern size_t + u32_grapheme_len (const uint32_t *s, size_t n); + +/* Returns the start of the next grapheme cluster following S, or NULL if the + end of the string has ben reached. */ +extern const uint8_t * + u8_grapheme_next (const uint8_t *s, const uint8_t *end); +extern const uint16_t * + u16_grapheme_next (const uint16_t *s, const uint16_t *end); +extern const uint32_t * + u32_grapheme_next (const uint32_t *s, const uint32_t *end); + +/* Returns the start of the previous grapheme cluster before S, or NULL if the + start of the string has ben reached. */ +extern const uint8_t * + u8_grapheme_prev (const uint8_t *s, const uint8_t *start); +extern const uint16_t * + u16_grapheme_prev (const uint16_t *s, const uint16_t *start); +extern const uint32_t * + u32_grapheme_prev (const uint32_t *s, const uint32_t *start); + +/* Determine the grapheme cluster boundaries in S, and store the result at + p[0..n-1]. p[i] = 1 means that a new grapheme cluster begins at s[i]. p[i] + = 0 means that s[i-1] and s[i] are part of the same grapheme cluster. p[0] + will always be 1. + */ +extern void + u8_grapheme_breaks (const uint8_t *s, size_t n, char *p); +extern void + u16_grapheme_breaks (const uint16_t *s, size_t n, char *p); +extern void + u32_grapheme_breaks (const uint32_t *s, size_t n, char *p); +extern void + ulc_grapheme_breaks (const char *s, size_t n, char *p); + /* ========================================================================= */ #ifdef __cplusplus