Function CE::Text::decode_utf8_scalar

Function Documentation

std::optional<Utf8Scalar> CE::Text::decode_utf8_scalar(std::string_view text, std::size_t offset) noexcept

Declaration: [[nodiscard]]

Decode at a byte offset; return nullopt at or beyond the view end.

Malformed input emits U+FFFD for one maximal subpart. Truncated prefixes are errors at this view’s end; this is not a streaming decoder. Retain stable input only for the call and advance by byte_count.

See also

UTF-8 decoding

Parameters:
  • text – Borrowed bytes; embedded NUL and BOM are decoded as scalars.

  • offset – Zero-based byte offset, not a scalar index.

Returns:

Owned scalar/source record with a positive byte_count within the view, or no result.