A single Unicode character.
More...
#include <yateclass.h>
|
enum | Endianness { LE = 0
, BE = 1
, Native = 2
} |
|
|
| UChar (uint32_t code=0) |
|
| UChar (int32_t code) |
|
| UChar (signed char code) |
|
| UChar (unsigned char code) |
|
UChar & | operator= (uint32_t code) |
|
UChar & | operator= (char code) |
|
uint32_t | code () const |
|
const char * | c_str () const |
|
| operator const char * () const |
|
bool | decode (const char *&str, uint32_t maxChar=0x10ffff, bool overlong=false) |
|
bool | decode (uint16_t *&buff, unsigned int &len, Endianness order, uint32_t maxChar=0x10ffff) |
|
bool | decode (DataBlock &buff, Endianness order, uint32_t maxChar=0x10ffff) |
|
bool | encode (uint16_t *&buff, unsigned int &len, Endianness order) |
|
bool | encode (DataBlock &buff, Endianness order) |
|
|
static bool | decode (String &out, uint16_t *&buff, unsigned int &len, Endianness order, bool checkBOM=false, uint32_t maxChar=0x10ffff) |
|
static bool | encode (DataBlock &out, const char *&str, Endianness order, bool addBOM=false) |
|
static bool | encode (uint16_t *&buff, unsigned int &len, const char *&str, Endianness order, bool addBOM=false) |
|
A single Unicode character.
A simple class to hold a single Unicode character and convert it to / from UTF-8
◆ UChar() [1/4]
UChar |
( |
uint32_t |
code = 0 | ) |
|
|
inlineexplicit |
Constructor from unsigned numeric code
- Parameters
-
code | Code of the Unicode character |
◆ UChar() [2/4]
Constructor from signed numeric code
- Parameters
-
code | Code of the Unicode character |
◆ UChar() [3/4]
UChar |
( |
signed char |
code | ) |
|
|
inlineexplicit |
Constructor from signed character
- Parameters
-
code | Character to construct from |
◆ UChar() [4/4]
UChar |
( |
unsigned char |
code | ) |
|
|
inlineexplicit |
Constructor from unsigned character
- Parameters
-
code | Character to construct from |
◆ c_str()
const char * c_str |
( |
| ) |
const |
|
inline |
Get the value of the character as UTF-8 string.
- Returns
- The character as UTF-8 C string
◆ code()
Get the Unicode value of the character
- Returns
- Code of the character as defined by Unicode
◆ decode() [1/4]
bool decode |
( |
const char *& |
str, |
|
|
uint32_t |
maxChar = 0x10ffff , |
|
|
bool |
overlong = false |
|
) |
| |
Decode the first Unicode character from an UTF-8 C string
- Parameters
-
str | String to extract from, will be advanced past the character |
maxChar | Maximum accepted Unicode character code |
overlong | Accept overlong UTF-8 sequences (dangerous!) |
- Returns
- True if an Unicode character was decoded from string
◆ decode() [2/4]
bool decode |
( |
DataBlock & |
buff, |
|
|
Endianness |
order, |
|
|
uint32_t |
maxChar = 0x10ffff |
|
) |
| |
Decode the first Unicode character from an UTF-16 string
- Parameters
-
buff | Input buffer from which to decode the character |
order | Endianness to use for decoding the character |
maxChar | Maximum accepted Unicode character code |
- Returns
- True if decoding succeeded, false otherwise
◆ decode() [3/4]
static bool decode |
( |
String & |
out, |
|
|
uint16_t *& |
buff, |
|
|
unsigned int & |
len, |
|
|
Endianness |
order, |
|
|
bool |
checkBOM = false , |
|
|
uint32_t |
maxChar = 0x10ffff |
|
) |
| |
|
static |
Decode a UTF-16 encoded string
- Parameters
-
out | String to append the decoded characters to |
buff | Input buffer to decode, advanced as decoding occurs |
len | Length of input buffer, decremented as decoding occurs |
order | Endianness to use for decoding |
checkBOM | Check for presence of BOM and interpret accordingly if present |
maxChar | Maximum accepted Unicode character code |
- Returns
- True if decoding succeeded, false otherwise
◆ decode() [4/4]
bool decode |
( |
uint16_t *& |
buff, |
|
|
unsigned int & |
len, |
|
|
Endianness |
order, |
|
|
uint32_t |
maxChar = 0x10ffff |
|
) |
| |
Decode the first Unicode character from an UTF-16 string
- Parameters
-
buff | Input buffer, advanced if decoding succeeds |
len | Length of input buffer, updated if decoding succeeds |
order | Endianness to use for decoding the character |
maxChar | Maximum accepted Unicode character code |
- Returns
- True if decoding succeeded, false otherwise
◆ encode() [1/4]
bool encode |
( |
DataBlock & |
buff, |
|
|
Endianness |
order |
|
) |
| |
Encode the Unicode character to UTF-16 into a DataBlock
- Parameters
-
buff | DataBlock to which the encoded character is to be appended |
order | Endianness to use for encoding the character |
- Returns
- True if decoding succeeded, false otherwise
◆ encode() [2/4]
static bool encode |
( |
DataBlock & |
out, |
|
|
const char *& |
str, |
|
|
Endianness |
order, |
|
|
bool |
addBOM = false |
|
) |
| |
|
static |
Encode a string to UTF-16
- Parameters
-
out | DataBlock to which encoded data is to be appended |
str | String to be encoded |
order | Endianness to use for encoding the character |
addBOM | True to add BOM to the resulting encoding |
- Returns
- True if encoding succeeded, false otherwise
◆ encode() [3/4]
static bool encode |
( |
uint16_t *& |
buff, |
|
|
unsigned int & |
len, |
|
|
const char *& |
str, |
|
|
Endianness |
order, |
|
|
bool |
addBOM = false |
|
) |
| |
|
static |
Encode a string to UTF-16 into a given buffer
- Parameters
-
buff | Buffer where to put encoded character, advanced after encoding |
len | Available space in given buffer, updated after encoding |
str | String to be encoded |
order | Endianness to use for encoding the character |
addBOM | True to add BOM to the resulting encoding |
- Returns
- True if encoding succeeded, false otherwise
◆ encode() [4/4]
bool encode |
( |
uint16_t *& |
buff, |
|
|
unsigned int & |
len, |
|
|
Endianness |
order |
|
) |
| |
Encode the Unicode character to UTF-16 into a given buffer
- Parameters
-
buff | Buffer where to put encoded character, advanced after encoding |
len | Available space in given buffer, updated after encoding |
order | Endianness to use for encoding the character |
- Returns
- True if decoding succeeded, false otherwise
◆ operator const char *()
operator const char * |
( |
| ) |
const |
|
inline |
Conversion to "const char *" operator.
- Returns
- Pointer to the internally stored UTF-8 string
◆ operator=() [1/2]
UChar & operator= |
( |
char |
code | ) |
|
|
inline |
Assignment operator from a character
- Parameters
-
- Returns
- Reference to this object
◆ operator=() [2/2]
UChar & operator= |
( |
uint32_t |
code | ) |
|
|
inline |
Assignment operator from a character code
- Parameters
-
code | Character code to assign |
- Returns
- Reference to this object
The documentation for this class was generated from the following file: