Struct GraphemeEnumerator
Enumerates extended grapheme clusters; get one from Graphemes(ReadOnlySpan<char>).
public ref struct GraphemeEnumerator
- Inherited Members
Examples
// A family emoji is one grapheme cluster of eight UTF-16 units; "can't" is one word.
string text = "\uD83D\uDC68\u200D\uD83D\uDC69\u200D\uD83D\uDC67 can't stop";
var graphemes = new List<TextSegment>();
foreach (TextSegment grapheme in TextSegmenter.Graphemes(text))
{
graphemes.Add(grapheme);
}
var words = new List<string>();
foreach (TextSegment word in TextSegmenter.Words(text))
{
words.Add(text.Substring(word.Start, word.Length));
}
bool inside = TextSegmenter.IsGraphemeBoundary(text, 2); // false: inside the family
Properties
Current
Gets the current cluster.
public readonly TextSegment Current { get; }
Property Value
Methods
GetEnumerator()
Returns this enumerator, for foreach.
public readonly GraphemeEnumerator GetEnumerator()
Returns
- GraphemeEnumerator
This enumerator.
MoveNext()
Moves to the next cluster.
public bool MoveNext()