Back to API Reference
Enum

TextLengthUnit

How text length is measured. The user-facing default is Graphemes — what a person counts as one character (a family emoji, an accented letter) — unlike codepoints or UTF-16 units, which can be higher than expected.

public static readonly TextLengthUnit Graphemes = 0

User-perceived characters (UAX #29 grapheme clusters). A ZWJ emoji or base + combining mark counts as one.

public static readonly TextLengthUnit Utf16Units = 1

UTF-16 code units — matches string.Length in C#/JS/Java, for parity with such a backend.

public static readonly TextLengthUnit Utf8Bytes = 2

UTF-8 bytes — for a field backed by a byte-sized DB column or wire field.

public static readonly TextLengthUnit Codepoints = 3

Unicode codepoints (scalar values). Surrogate-safe, but still splits emoji/ZWJ sequences.