GREM 3.12.0
Game/Rendering Engine Modules for C++
Loading...
Searching...
No Matches
grem::unicode Namespace Reference

Classes

struct  UTF8Sentinel
 Sentinel type for UTF8Iterator. More...
class  UTF8Iterator
 Iterator type for decoding Unicode code points from a UTF-8 string, wrapping an existing iterator for UTF-8 code units. More...
class  UTF8Iterator< BaseIterator, BaseSentinel >
 Specialization of UTF8Iterator that provides forward iteration capability (and an optimized implementation) for base iterators that support it. More...
class  UTF8View
 Non-owning view type for decoding Unicode code points from a contiguous UTF-8 string. More...

Functions

constexpr bool isValidCodePoint (char32_t codePoint) noexcept
 Check if a 32-bit unsigned integer value falls within the valid ranges for a Unicode code point.
template<input_iterator InputIterator, sentinel_for< InputIterator > Sentinel>
constexpr Pair< char32_t, InputIterator > decodeCodePointFromUTF8 (InputIterator it, Sentinel end)
 Decode a single Unicode code point from an iterator of UTF-8 code units in a UTF-8-encoded string.
constexpr InplaceBuffer< char8_t, 4 > encodeUTF8FromCodePoint (char32_t codePoint) noexcept
 Encode a Unicode code point into a sequence of UTF-8 code units.

Variables

constexpr char32_t CODE_POINT_ERROR {0xFFFFFFFF}
 Invalid code point value, used as a return value in Unicode decoding algorithms for conveying encoding errors.

Function Documentation

◆ isValidCodePoint()

bool grem::unicode::isValidCodePoint ( char32_t codePoint)
nodiscardconstexprnoexcept

Check if a 32-bit unsigned integer value falls within the valid ranges for a Unicode code point.

Parameters
codePoint32-bit code point value to check.
Returns
true if the code unit is a valid code point, false otherwise.

◆ decodeCodePointFromUTF8()

template<input_iterator InputIterator, sentinel_for< InputIterator > Sentinel>
Pair< char32_t, InputIterator > grem::unicode::decodeCodePointFromUTF8 ( InputIterator it,
Sentinel end )
nodiscardconstexpr

Decode a single Unicode code point from an iterator of UTF-8 code units in a UTF-8-encoded string.

Parameters
itinput iterator to a sequence of UTF-8 code units. The expression *it++ must be convertible to char8_t.
endend iterator or sentinel that marks the end of the UTF-8 code unit sequence.
Returns
a pair of:
  • the decoded Unicode code point, or CODE_POINT_ERROR on failure to decode a code point due to an encoding error in the UTF-8 string, and
  • the input iterator, positioned at the start of the next UTF-8 code unit after the parsed code point sequence.
Exceptions
anyexception thrown by the iterator implementation.

◆ encodeUTF8FromCodePoint()

InplaceBuffer< char8_t, 4 > grem::unicode::encodeUTF8FromCodePoint ( char32_t codePoint)
nodiscardconstexprnoexcept

Encode a Unicode code point into a sequence of UTF-8 code units.

Parameters
codePointcode point to encode.
Returns
a list of up to 4 UTF-8 code units.
Note
The returned array of code units is NOT guaranteed to be null-terminated. Its size method must be used to determine the actual length of the code point sequence.

Variable Documentation

◆ CODE_POINT_ERROR

char32_t grem::unicode::CODE_POINT_ERROR {0xFFFFFFFF}
inlineconstexpr

Invalid code point value, used as a return value in Unicode decoding algorithms for conveying encoding errors.