Skip to content

Latest commit

 

History

History
125 lines (78 loc) · 5.12 KB

File metadata and controls

125 lines (78 loc) · 5.12 KB

ConsolePlus

StringExtensions Class

Provides extension methods for strings.

public static class StringExtensions

Inheritance System.Object → StringExtensions

Methods

StringExtensions.GetDisplayLength(this string) Method

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);

Parameters

text System.String

The text to calculate the display length for.

Returns

System.Int32[]
An array containing the display length of each line in the text.

StringExtensions.GetRuneWidth(this Rune) Method

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);

Parameters

rune System.Text.Rune

The rune to measure.

Returns

System.Int32
The display width, in columns, of rune.

StringExtensions.NormalizeNewLines(this string) Method

Normalizes the new lines in the specified text.

public static string NormalizeNewLines(this string? text);

Parameters

text System.String

The text to normalize.

Returns

System.String
The text with normalized new lines.

StringExtensions.SplitLines(this string) Method

Splits the specified text into lines, normalizing the new lines in the process.

public static string[] SplitLines(this string text);

Parameters

text System.String

Returns

System.String[]

StringExtensions.TruncateToDisplayWidth(this string, int) Method

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);

Parameters

text System.String

The text to truncate.

maxWidth System.Int32

The maximum display width, in columns, of the returned prefix.

Returns

System.String
The truncated text. Empty when maxWidth is not positive.