Table of Contents

Class GraphemeHelper

Namespace
Terminal.Gui.Drawing
Assembly
Terminal.Gui.dll

Provides utility methods for enumerating Unicode grapheme clusters (user-perceived characters) in a string. A grapheme cluster may consist of one or more Rune values, including combining marks or zero-width joiner (ZWJ) sequences such as emoji family groups.

public static class GraphemeHelper
Inheritance
GraphemeHelper
Inherited Members

Remarks

This helper uses GetTextElementEnumerator(string) to enumerate text elements according to the Unicode Standard Annex #29 (UAX #29) rules for extended grapheme clusters.

On legacy Windows consoles (e.g., cmd.exe, conhost.exe), complex grapheme sequences such as ZWJ emoji or combining marks may not render correctly, even though the underlying string data is valid.

For most accurate visual rendering, prefer modern terminals such as Windows Terminal or Linux-based terminals with full Unicode and font support.

Methods

GetGraphemeCount(string)

Counts the number of grapheme clusters in a string without allocating intermediate collections.

GetGraphemes(string)

Enumerates extended grapheme clusters from a string. Handles surrogate pairs, combining marks, and basic ZWJ sequences. Safe for legacy consoles; memory representation is correct.