Grapheme clusters v0.1.0
Extended grapheme cluster boundaries, and how many user-perceived characters a text holds.
IsGraphemeBoundary
pub func IsGraphemeBoundary(
text: char32[..],
index: uint
) -> bool
Whether a cluster boundary falls before index in text.
The ends count: position zero and the length are always boundaries, which is what makes "the clusters of a
text" a partition of it. The rules between are UAX #29's, applied to the pair either side of the position with
lookback where a rule reaches further — the emoji join, the flag pairs, and the Indic conjuncts.
Runs in time proportional to the lookback, which is the run of marks behind the position; allocates nothing.
Parameters
| Name | Type | Description |
|---|---|---|
text | char32[..] | the scalar values to examine |
index | uint | the position to test, in scalar values |
Returns: whether a grapheme cluster boundary falls before index
CountGraphemes
pub func CountGraphemes(text: char32[..]) -> uint
How many grapheme clusters text holds.
Parameters
| Name | Type | Description |
|---|---|---|
text | char32[..] | the scalar values to count |
Returns: how many grapheme clusters text holds