Skip to content

UTF8

#include <tpau-cpp-kernal/UTF8.h>

INCLUDE FILE
#include <tpau-cpp-kernal/UTF8.h>

class UTF8

Utility functions for working with UTF-8 and Unicode code-points.

DEFINITION
class UTF8;

method decodestatic

Decodes a UTF-8 string into a sequence of Unicode code-points.

DEFINITION
static std::u32string  decode ( const std::string & string );
PARAMETERDESCRIPTION
string

The UTF-8 string to decode.

RETURNSDESCRIPTION
std::u32string

A sequence of Unicode code-points.

method encodestatic

Encodes a Unicode code-point into a UTF-8 string.

DEFINITION
static std::string  encode ( char32_t  codepoint,
bool  escape_non_printable = false );
PARAMETERDESCRIPTION
codepoint

The Unicode code-point to encode.

escape_non_printable

If true, non-printable characters will be escaped as \uXXXX.

RETURNSDESCRIPTION
std::string

The UTF-8 encoded string.

method encodestatic

Encodes a sequence of Unicode code-points into a UTF-8 string.

DEFINITION
static std::string  encode ( const std::u32string & string );
PARAMETERDESCRIPTION
string

The sequence of Unicode code-points to encode.

RETURNSDESCRIPTION
std::string

The UTF-8 encoded string.

method is_printablestatic

Checks if a Unicode code-point is printable.

DEFINITION
static bool  is_printable ( char32_t  codepoint );
PARAMETERDESCRIPTION
codepoint

The Unicode code-point to check.

RETURNSDESCRIPTION
bool

True if the code-point is printable, false otherwise.