Provides extension methods for strings.
public static class StringExtensionsInheritance System.Object → StringExtensions
Calculates the display length of each line in the specified text, taking into account the width of Unicode characters.
public static int[] GetDisplayLength(this string? text);text System.String
The text to calculate the display length for.
System.Int32[]
An array containing the display length of each line in the text.
Returns the display width, in terminal columns, of a single rune (0 for combining/control runes, 2 for East Asian wide runes, 1 otherwise).
public static int GetRuneWidth(this System.Text.Rune rune);rune System.Text.Rune
The rune to measure.
System.Int32
The display width, in columns, of rune.
Normalizes the new lines in the specified text.
public static string NormalizeNewLines(this string? text);text System.String
The text to normalize.
System.String
The text with normalized new lines.
Splits the specified text into lines, normalizing the new lines in the process.
public static string[] SplitLines(this string text);text System.String
Returns the longest prefix of text whose display width does not exceed maxWidth columns, without splitting a wide rune in half.
public static string TruncateToDisplayWidth(this string? text, int maxWidth);text System.String
The text to truncate.
maxWidth System.Int32
The maximum display width, in columns, of the returned prefix.
System.String
The truncated text. Empty when maxWidth is not positive.