Back to API Reference
Class

TextMeasure

static

Measures and truncates text by TextLengthUnit. Truncation cuts only on a codepoint or grapheme boundary, so it never splits a surrogate pair, a multi-byte codepoint, or a grapheme cluster.

public static int Count()

Length of text in unit.

public static int Count()

Length of the whole document in unit. Measures the document SOURCE — in a markup-bearing field hidden tag characters count too; keep limits and counters on plain fields, or accept that they measure source, not the visible projection. For the per-keystroke grapheme path prefer GraphemeCountCache.

public static int CountRange()

Length of the document's codepoint range [startCodepoint, startCodepoint + codepointCount) in unit.

public static int TruncatedCharLength()

Char count of the longest prefix of text whose length in unit is at most budget, cut on a boundary. Pass the result to Substring.