class UTF8

Provides methods to converting between UTF-8 character encoding and other popular encodings.

Public

Methods

staticFromAnsi

static String FromAnsi(const String &input, const std::locale &locale = std::locale(""))

Converts from an ANSI encoding in the specified locale into UTF-8.

input
Narrow string encoded as ANSI characters. Characters are expected to be in the code page specified by .
locale
Locale that determines how are the ANSI characters interpreted.

Returns: UTF-8 encoded string.

staticToAnsi

static String ToAnsi(const String &input, const std::locale &locale = std::locale(""), char invalidChar = 0)

Converts from an UTF-8 encoding into ANSI encoding in the specified locale.

input
Narrow string encoded as UTF-8 characters.
locale
Locale that determines from which code page to generate the ANSI characters.
invalidChar
Character that will be used when an Unicode character cannot be represented using the selected ANSI code page.

Returns: ANSI encoded string in the specified locale.

staticFromWide

static String FromWide(const WString &input)

Converts from a system-specific wide character encoding into UTF-8.

input
Wide string to convert. Actual encoding is system specific be can be assumed to be UTF-16 on Windows and UTF-32 on Unix.

Returns: UTF-8 encoded string.

staticToWide

static WString ToWide(const String &input)

Converts from an UTF-8 encoding into system-specific wide character encoding.

input
Narrow string encoded as UTF-8 characters.

Returns: Wide string encoded in a system-specific manner. Actual encoding can be assumed to be UTF-16 on Windows and UTF-32 and Unix.

staticFromUtF16

static String FromUtF16(const U16String &input)

Converts from an UTF-16 encoding into UTF-8.

input
String encoded as UTF-16.

Returns: UTF-8 encoded string.

staticToUtF16

static U16String ToUtF16(const String &input)

Converts from an UTF-8 encoding into UTF-16.

input
String encoded as UTF-8.

Returns: UTF-16 encoded string.

staticFromUtF32

static String FromUtF32(const U32String &input)

Converts from an UTF-32 encoding into UTF-8.

input
String encoded as UTF-32.

Returns: UTF-8 encoded string.

staticToUtF32

static U32String ToUtF32(const String &input)

Converts from an UTF-8 encoding into UTF-32.

input
String encoded as UTF-8.

Returns: UTF-32 encoded string.

staticCount

static u32 Count(const String &input)

Counts the number of characters in the provided UTF-8 input string.

staticToLower

static String ToLower(const String &input)

Converts the provided UTF8 encoded string to lowercase.

staticToUpper

static String ToUpper(const String &input)

Converts the provided UTF8 encoded string to uppercase.

staticCharToByteIndex

static u32 CharToByteIndex(const String &input, u32 charIdx)

Returns the byte at which the character with the specified index starts.

The string is expected to be in UTF-8 encoding. If is out of range the method returns the index past the last byte in the string (same as the string length in bytes).

staticCharByteCount

static u32 CharByteCount(const String &input, u32 charIdx)

Calculates the number of bytes taken up by the character at the specified position.