Unicode-aware character class wrapping a single codepoint. More...
#include <char.h>
Public Member Functions | |
| Char () | |
| Constructs a null character (U+0000). | |
| Char (char c) | |
| Constructs from a Latin1 byte (0x00–0xFF). | |
| Char (char32_t cp) | |
| Constructs from a Unicode codepoint. | |
| char32_t | codepoint () const |
| Returns the Unicode codepoint. | |
| bool | isNull () const |
| Returns true if this is the null character. | |
| bool | isAscii () const |
| Returns true if the codepoint is in the ASCII range (< 0x80). | |
| bool | isAlpha () const |
| Returns true if the character is alphabetic. | |
| bool | isDigit () const |
| Returns true if the character is a decimal digit. | |
| bool | isAlphaNumeric () const |
| Returns true if the character is alphanumeric. | |
| bool | isSpace () const |
| Returns true if the character is whitespace. | |
| bool | isUpper () const |
| Returns true if the character is uppercase. | |
| bool | isLower () const |
| Returns true if the character is lowercase. | |
| bool | isPrintable () const |
| Returns true if the character is printable. | |
| Char | toUpper () const |
| Returns the uppercase version of this character. | |
| Char | toLower () const |
| Returns the lowercase version of this character. | |
| size_t | utf8ByteCount () const |
| Returns the number of bytes needed to encode this codepoint as UTF-8 (1–4). | |
| size_t | toUtf8 (char *buf) const |
| Encodes this codepoint as UTF-8 into the given buffer. | |
| bool | operator== (Char o) const |
| bool | operator== (char c) const |
| bool | operator!= (Char o) const |
| bool | operator< (Char o) const |
| bool | operator<= (Char o) const |
| bool | operator> (Char o) const |
| bool | operator>= (Char o) const |
Static Public Member Functions | |
| static Char | fromUtf8 (const char *buf, size_t *bytesRead=nullptr) |
| Decodes a single UTF-8 codepoint from the given buffer. | |
Unicode-aware character class wrapping a single codepoint.
Stores a char32_t codepoint and provides character classification, case conversion, and UTF-8 encoding/decoding.
Decodes a single UTF-8 codepoint from the given buffer.
| buf | Pointer to UTF-8 bytes. |
| bytesRead | If non-null, set to the number of bytes consumed. |
Encodes this codepoint as UTF-8 into the given buffer.
| buf | Buffer of at least 4 bytes. |