ReadCode(ReadOnlySpan) Method

Definition

Namespace Broadside.Fonts
Assembly Broadside.dll

Reads the character code at the start of text.

public CharacterCode ReadCode(ReadOnlySpan<byte> text)

Parameters

text
ReadOnlySpan<Byte>

The rest of a string shown in a composite font.

Returns

CharacterCode
The code and its length. An invalid code (one in no codespace range) is returned with IsValid false and the length of the codespace range that best matches its first bytes; never more bytes than text has. An empty text gives a code of length 0.

Remarks

ISO 32000-2 §9.7.6.2: one byte is matched against the one-byte codespace ranges, then two against the two-byte ranges, up to four. §9.7.6.3 for an invalid code: when no range admits its first byte, the shortest codes are used; otherwise the range matching the most leading bytes (the shortest of equals) gives the length. Allocates nothing.