decodeUtf8

public func decodeUtf8(lang.ptr[lang.i8], Int64, at: Int64) -> Utf8DecodeResult?

Decodes one UTF-8 character starting at index inside the buffer of length bytes pointed to by ptr.

Returns Some(Utf8DecodeResult) on success, where bytesConsumed is 14. Returns None for any of the malformed-input cases: truncated multi-byte sequence, continuation byte where a leading byte was expected, or invalid leading byte (0xF80xFF). Does not validate against overlong encodings or surrogate-range scalars — feed only well-formed UTF-8 if those matter.

Safety

ptr must be valid for length bytes. The function bounds-checks index and any continuation bytes against length.

Examples

var result = String("hé"); // Conceptually: // decodeUtf8(rawPtr, 3, at: 0) // Some(char: 'h', bytesConsumed: 1) // decodeUtf8(rawPtr, 3, at: 1) // Some(char: 'é', bytesConsumed: 2) // decodeUtf8(rawPtr, 3, at: 3) // None (past the end)

Defined in lang/std/text/char.ks