Utf8DecodeResult

public struct Utf8DecodeResult { /* private fields */ }

The output of decoding one UTF-8 character from a byte buffer.

Carries both the decoded Char and the number of bytes consumed, so the caller can advance their cursor without re-running utf8Length(). Returned as Some from decodeUtf8; None indicates an invalid or truncated sequence.

Examples

let r = Utf8DecodeResult(char: 'a', bytesConsumed: 1); r.char; // 'a' r.bytesConsumed; // 1

Representation

A plain pair (char: Char, bytesConsumed: Int64). Both fields are public to keep the type cheap to inspect.

Properties

public var bytesConsumed: Int64

How many bytes the encoded form occupied (1–4).

public var char: Char

The decoded character.

Initializers

public init(char: Char, bytesConsumed: Int64)

Constructs a decode result from an already-decoded char and byte length.

Mainly used by decodeUtf8 itself; user code rarely needs to build one directly.

Defined in lang/std/text/char.ks