libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
Char Class Reference

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.
 

Detailed Description

Unicode-aware character class wrapping a single codepoint.

Stores a char32_t codepoint and provides character classification, case conversion, and UTF-8 encoding/decoding.

Member Function Documentation

◆ fromUtf8()

static Char Char::fromUtf8 ( const char buf,
size_t bytesRead = nullptr 
)
static

Decodes a single UTF-8 codepoint from the given buffer.

Parameters
bufPointer to UTF-8 bytes.
bytesReadIf non-null, set to the number of bytes consumed.
Returns
The decoded character.

◆ toUtf8()

size_t Char::toUtf8 ( char buf) const

Encodes this codepoint as UTF-8 into the given buffer.

Parameters
bufBuffer of at least 4 bytes.
Returns
Number of bytes written.

The documentation for this class was generated from the following file: