Grapheme cluster breaks in strings <unigbrk.h>
**********************************************

This include file declares functions for determining where in a string ``grapheme clusters'' start and end.  A ``grapheme cluster'' is an approximation to a user-perceived character, which sometimes corresponds to multiple Unicode characters.  Editing operations such as mouse selection, cursor movement, and backspacing often operate on grapheme clusters as units, not on individual characters.

Some grapheme clusters are built from a base character and a combining character.  The letter é, for example, is most commonly represented in Unicode as a single character U+00E8 LATIN SMALL LETTER E WITH ACUTE.  It is, however, equally valid to use the pair of characters U+0065 LATIN SMALL LETTER E followed by U+0301 COMBINING ACUTE ACCENT.  Since the user would perceive this pair of characters as a single character, they would be grouped into a single grapheme cluster.

But there are also grapheme clusters that consist of several base characters. For example, a Devanagari letter and a Devanagari vowel sign that follows it may form a grapheme cluster.  Similarly, some pairs of Thai characters and Hangul syllables (formed by two or three Hangul characters) are grapheme clusters.

Grapheme cluster breaks in a string
===================================

The following functions find a single boundary between grapheme clusters in a string.

 -- Function: void u8_grapheme_next (const uint8_t *S, const uint8_t *END)
 -- Function: void u16_grapheme_next (const uint16_t *S, const uint16_t *END)
 -- Function: void u32_grapheme_next (const uint32_t *S, const uint32_t *END)
     Returns the start of the next grapheme cluster following S, or END if no grapheme cluster break is encountered before it. Returns NULL if and only if S == END.

 -- Function: void u8_grapheme_prev (const uint8_t *S, const uint8_t *START)
 -- Function: void u16_grapheme_prev (const uint16_t *S, const uint16_t *START)
 -- Function: void u32_grapheme_prev (const uint32_t *S, const uint32_t *START)
     Returns the start of the grapheme cluster preceding S, or START if no grapheme cluster break is encountered before it. Returns NULL if and only if S == START.

The following functions determine all of the grapheme cluster boundaries in a string.

 -- Function: void u8_grapheme_breaks (const uint8_t *S, size_t N, char *P)
 -- Function: void u16_grapheme_breaks (const uint16_t *S, size_t N, char *P)
 -- Function: void u32_grapheme_breaks (const uint32_t *S, size_t N, char *P)
 -- Function: void ulc_grapheme_breaks (const char *S, size_t N, char *P)
     Determines the grapheme cluster break points in S, an array of N units, and stores the result at P[0..N-1].

     P[i] = 1
          means that there is a grapheme cluster boundary between S[i-1] and S[i].

     P[i] = 0
          means that S[i-1] and S[i] are part of the same grapheme cluster.

     P[0] is always set to 1, because there is always a grapheme cluster break at start of text.

Grapheme cluster break property
===============================

This is a more low-level API.  The grapheme cluster break property is a property defined in Unicode Standard Annex #29, section ``Grapheme Cluster Boundaries'', see http://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries.texnl It is used for determining the grapheme cluster breaks in a string.

The following are the possible values of the grapheme cluster break property.  More values may be added in the future.

 -- Constant: int GBP_OTHER
 -- Constant: int GBP_CR
 -- Constant: int GBP_LF
 -- Constant: int GBP_CONTROL
 -- Constant: int GBP_EXTEND
 -- Constant: int GBP_PREPEND
 -- Constant: int GBP_SPACINGMARK
 -- Constant: int GBP_L
 -- Constant: int GBP_V
 -- Constant: int GBP_T
 -- Constant: int GBP_LV
 -- Constant: int GBP_LVT

The following function looks up the grapheme cluster break property of a character.

 -- Function: int uc_graphemeclusterbreak_property (ucs4_t UC)
     Returns the Grapheme_Cluster_Break property of a Unicode character.

The following function determines whether there is a grapheme cluster break between two Unicode characters.  It is the primitive upon which the higher-level functions in the previous section are directly based.

 -- Function: bool uc_is_grapheme_break (ucs4_t A, ucs4_t B)
     Returns true if there is an grapheme cluster boundary between Unicode characters A and B.

     There is always a grapheme cluster break at the start or end of text. You can specify zero for A or B to indicate start of text or end of text, respectively.

     This implements the extended (not legacy) grapheme cluster rules described in the Unicode standard, because the standard says that they are preferred.