Class UnicodeWidth
- Namespace
- MiniTui
- Assembly
- MiniTui.dll
Display width of text in terminal columns, by grapheme cluster (UAX #29).
Width tables come from Unicode 16.0; see tools/GenWidthTable.cs.
public static class UnicodeWidth
- Inheritance
-
UnicodeWidth
- Inherited Members
Methods
Graphemes(string)
Split text into grapheme clusters (StringInfo text elements).
public static IEnumerable<string> Graphemes(string text)
Parameters
textstring
Returns
Of(ReadOnlySpan<char>)
Total display width of text: the sum over its grapheme clusters.
public static int Of(ReadOnlySpan<char> text)
Parameters
textReadOnlySpan<char>
Returns
OfGrapheme(ReadOnlySpan<char>)
Display width of a single grapheme cluster: 0, 1 or 2.
public static int OfGrapheme(ReadOnlySpan<char> grapheme)
Parameters
graphemeReadOnlySpan<char>
Returns
Truncate(string, int, string)
Truncate text to at most maxWidth columns. If it doesn't fit, as many whole
grapheme clusters as fit are kept and ellipsis is appended.
public static string Truncate(string text, int maxWidth, string ellipsis = "…")