|
| constexpr size_t | num_bytes (char8_t c) noexcept |
| | Returns the expected number of bytes for an UTF-8 char sequence by inspecting the first byte.
|
| constexpr char32_t | append (char32_t c, char8_t b) noexcept |
| | Append b to c for converting UTF-8 to UTF-32.
|
| constexpr char32_t | first (char32_t c, char32_t num) noexcept |
| | Get relevant bits of first UTF-8 byte c of a multi-byte sequence consisting of num bytes.
|
| constexpr char32_t | min_code_point (size_t num) noexcept |
| | Minimum Unicode scalar value representable in an UTF-8 sequence of num bytes.
|
| constexpr char8_t | is_valid234 (char8_t c) noexcept |
| | Is the 2nd, 3rd, or 4th byte of an UTF-8 byte sequence valid?
|
| constexpr bool | is_scalar_value (char32_t c) noexcept |
| | Is c a valid Unicode scalar value?
|
| char32_t | decode (std::istream &is) |
| | Decodes the next UTF-8 sequence from is into a single char32_t.
|
| char32_t | decode (std::string_view str, size_t &i) noexcept |
| | Decodes the UTF-8 sequence at i in str and advances i past it.
|
| size_t | num_code_points (std::string_view str) noexcept |
| | Number of UTF-8 code points in str.
|
| bool | encode (std::ostream &os, char32_t c32) |
| | Encodes c32 as UTF-8 and writes the resulting bytes to os.
|
| template<class... T> |
| constexpr auto | any (T... args) noexcept |
| | Build a predicate that checks whether a code point matches any of the given values.
|
char32_t-style counterparts of the <ctype> functions, for a code point of any width - everything above U+00FF belongs to no class.
|
| constexpr bool | isascii (char32_t c) noexcept |
| constexpr bool | isupper (char32_t c) noexcept |
| constexpr bool | islower (char32_t c) noexcept |
| constexpr bool | isdigit (char32_t c) noexcept |
| constexpr bool | isalpha (char32_t c) noexcept |
| constexpr bool | isalnum (char32_t c) noexcept |
| constexpr bool | isxdigit (char32_t c) noexcept |
| constexpr bool | iscntrl (char32_t c) noexcept |
| constexpr bool | isblank (char32_t c) noexcept |
| constexpr bool | isspace (char32_t c) noexcept |
| constexpr bool | isgraph (char32_t c) noexcept |
| constexpr bool | isprint (char32_t c) noexcept |
| constexpr bool | ispunct (char32_t c) noexcept |
| constexpr char32_t | tolower (char32_t c) noexcept |
| constexpr char32_t | toupper (char32_t c) noexcept |
| constexpr bool | isrange (char32_t c, char32_t begin, char32_t finis) noexcept |
| | Is c within [begin, finis]?
|
| constexpr auto | isrange (char32_t begin, char32_t finis) noexcept |
| constexpr bool | isodigit (char32_t c) noexcept |
| | Is octal digit?
|
| constexpr bool | isbdigit (char32_t c) noexcept |
| | Is binary digit?
|
|
| static constexpr size_t | Max = 4 |
| | Maximal number of char8_ts of an UTF-8 byte sequence.
|
| static constexpr char32_t | BOM = 0xfeff |
| | Byte Order Mark.
|
| static constexpr std::string_view | Bom = "\xef\xbb\xbf" |
| | BOM as UTF-8 bytes.
|
| static constexpr char32_t | EoF = (char32_t)std::istream::traits_type::eof() |
| | End of stream sentinel returned by decode.
|
| static constexpr char32_t | Null = 0 |
| | U+0000 NULL returned unchanged by decode.
|
| static constexpr char32_t | Invalid = 0x110000 |
| | Sentinel returned by decode for malformed UTF-8.
|
UTF-8 helpers for decoding byte streams, encoding char32_t values, and running ASCII-style character classification on char32_t.
The central entry points are decode and encode. Decoding returns sentinel values such as EoF and Invalid instead of throwing.
| char32_t fe::utf8::decode |
( |
std::istream & | is | ) |
|
|
inline |
Decodes the next UTF-8 sequence from is into a single char32_t.
Returns EoF when the stream is exhausted and Invalid for malformed, overlong, surrogate, or otherwise non-scalar encodings.
Definition at line 64 of file utf8.h.
References append(), decode(), EoF, first(), Invalid, is_scalar_value(), is_valid234(), min_code_point(), and num_bytes().
Referenced by decode(), and decode().
| char32_t fe::utf8::decode |
( |
std::string_view | str, |
|
|
size_t & | i ) |
|
inlinenoexcept |
Decodes the UTF-8 sequence at i in str and advances i past it.
Returns EoF at the end of str - leaving i alone - and Invalid for malformed, overlong, surrogate, or otherwise non-scalar encodings.
- Note
- An Invalid sequence advances
i by a single byte, so the next decode resynchronizes instead of swallowing bytes that may well start a valid sequence themselves.
Definition at line 92 of file utf8.h.
References append(), decode(), EoF, first(), Invalid, is_scalar_value(), is_valid234(), min_code_point(), and num_bytes().