Yate
|
A single Unicode character. More...
#include <yateclass.h>
Public Types | |
enum | Endianness { LE = 0, BE = 1, Native = 2 } |
Public Member Functions | |
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 Public Member Functions | |
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
|
inlineexplicit |
Constructor from unsigned numeric code
code | Code of the Unicode character |
References UChar::encode().
|
inlineexplicit |
Constructor from signed numeric code
code | Code of the Unicode character |
References UChar::encode().
|
inlineexplicit |
Constructor from signed character
code | Character to construct from |
References UChar::encode().
|
inlineexplicit |
Constructor from unsigned character
code | Character to construct from |
References UChar::encode().
|
inline |
Get the value of the character as UTF-8 string.
|
inline |
Get the Unicode value of the character
Referenced by UChar::operator=().
bool decode | ( | const char *& | str, |
uint32_t | maxChar = 0x10ffff , |
||
bool | overlong = false |
||
) |
Decode the first Unicode character from an UTF-8 C string
str | String to extract from, will be advanced past the character |
maxChar | Maximum accepted Unicode character code |
overlong | Accept overlong UTF-8 sequences (dangerous!) |
bool decode | ( | uint16_t *& | buff, |
unsigned int & | len, | ||
Endianness | order, | ||
uint32_t | maxChar = 0x10ffff |
||
) |
Decode the first Unicode character from an UTF-16 string
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 |
bool decode | ( | DataBlock & | buff, |
Endianness | order, | ||
uint32_t | maxChar = 0x10ffff |
||
) |
Decode the first Unicode character from an UTF-16 string
buff | Input buffer from which to decode the character |
order | Endianness to use for decoding the character |
maxChar | Maximum accepted Unicode character code |
|
static |
Decode a UTF-16 encoded string
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 |
bool encode | ( | uint16_t *& | buff, |
unsigned int & | len, | ||
Endianness | order | ||
) |
Encode the Unicode character to UTF-16 into a given buffer
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 |
Referenced by UChar::operator=(), and UChar::UChar().
bool encode | ( | DataBlock & | buff, |
Endianness | order | ||
) |
|
static |
|
static |
Encode a string to UTF-16 into a given buffer
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 |
|
inline |
Conversion to "const char *" operator.
|
inline |
Assignment operator from a character code
code | Character code to assign |
References UChar::code(), and UChar::encode().
|
inline |
Assignment operator from a character
code | Character to assign |
References UChar::encode().