muu::utf8_decoder class

A state machine for decoding UTF-8 data.

The implementation of this decoder is based on this: https://bjoern.hoehrmann.de/utf-8/decoder/dfa/

Public functions

void clear_error() constexpr noexcept
Clears the error state.
auto error() const -> bool constexpr noexcept
Returns true if the decoder has entered an error state.
auto has_value() const -> bool constexpr noexcept
Returns true if the decoder has a decoded a full UTF-32 codepoint.
auto needs_more_input() const -> bool constexpr noexcept
Returns true if the decoder needs more input before it can yield a UTF-32 codepoint.
void operator()(uint8_t code_unit) constexpr noexcept
Appends a UTF-8 code unit to the stream being decoded.
void operator()(char code_unit) constexpr noexcept
Appends a UTF-8 code unit to the stream being decoded.
void operator()(char8_t code_unit) constexpr noexcept
Appends a UTF-8 code unit to the stream being decoded.
auto value() const -> char32_t constexpr noexcept
Returns the currently-decoded UTF-32 codepoint.