This module provides support to handle unicode extended grapheme clusters, as in "user perceived characters".
Procs
proc graphemes(s: string): seq[string] {...}{.raises: [], tags: [].}
- Return the grapheme sequence of s
proc graphemesReversed(s: string): seq[string] {...}{.raises: [], tags: [].}
- Return the grapheme sequence of s in reverse order
proc graphemeLenAt(s: string; i: Natural): int {...}{.raises: [], tags: [].}
- Return the number of bytes in the grapheme starting at s[i]
proc graphemeLenAt(s: string; i: BackwardsIndex): int {...}{.raises: [], tags: [].}
- Return the number of bytes in the grapheme ending at s[^i]
proc graphemesCount(s: string): int {...}{.raises: [], tags: [].}
- Return the number of graphemes in s
proc graphemesSubStr(s: string; first: int; last = int.high): string {...}{.raises: [], tags: [].}
- Return the sub-string starting at the first grapheme and ending at the last grapheme. Return from first to the end of the string, if last is not provided. Beware this function always iterates from the start of the string to get to the first grapheme.
Funcs
func graphemesReverse(s: var string) {...}{.inline, raises: [], tags: [].}
- Reverse graphemes of s in-place
Iterators
iterator graphemeBounds(s: string): Slice[int] {...}{.inline, raises: [], tags: [].}
- Return grapheme boundaries in s. Boundaries are inclusive
iterator graphemes(s: string): string {...}{.inline, raises: [], tags: [].}
- Iterate s returning graphemes
iterator graphemeBoundsReversed(s: string): Slice[int] {...}{.inline, raises: [], tags: [].}
- Return grapheme boundaries of s in reverse order. Boundaries are inclusive
iterator graphemesReversed(s: string): string {...}{.inline, raises: [], tags: [].}
- Return graphemes of s in reverse order