aes70::UTF8 namespace

Contents

This namespace contains some functions for handling UTF-8 encoded data.

Functions

static auto next_codepoint(const uint8_t* src) -> const uint8_t*
static auto decode_length(const uint8_t* src, std::size_t codepoints) -> std::size_t noexcept
static auto decode_length(const uint8_t* src, const uint8_t* end, std::size_t codepoints) -> const uint8_t* noexcept
static auto count_codepoints(const uint8_t* src, const uint8_t* end) -> std::size_t
static auto count_codepoints(const uint8_t* src, std::size_t len) -> std::size_t

Function documentation

static const uint8_t* aes70::UTF8::next_codepoint(const uint8_t* src)

Returns the start position of the next codepoint. If the current codepoint starts with an invalid byte, nullptr is returned.

static std::size_t aes70::UTF8::decode_length(const uint8_t* src, std::size_t codepoints) noexcept

Return the number of bytes occupied by the given number of code points in the buffer src. Only use this function if you are certain that the buffer actually contains that many code points.

static const uint8_t* aes70::UTF8::decode_length(const uint8_t* src, const uint8_t* end, std::size_t codepoints) noexcept

Return the number of bytes occupied by the given number of code points in the buffer src. Returns a pointer to the next byte after the UTF-8 encoded data, OR nullptr if the buffer does not contain enough data.

static std::size_t aes70::UTF8::count_codepoints(const uint8_t* src, const uint8_t* end)

Count the number of UTF-8 encoded code points in the buffer between src and end.

static std::size_t aes70::UTF8::count_codepoints(const uint8_t* src, std::size_t len)

Count the number of UTF-8 encoded code points in the buffer between src and src + len.