Unicode encoding/decoding
Functions
-
constexpr usize utf8_charspan(c32 ch)
Gets the number of UTF-8 characters needed to store the Unicode char in UTF-8 encoding.
-
constexpr usize utf8_charlen(c8 ch)
Gets the number of UTF-8 characters the Unicode character takes from the first UTF-8 character.
-
constexpr usize utf8_charlen(const c8 *src)
Gets the number of UTF-8 characters the Unicode character takes from the first UTF-8 character.
-
constexpr usize utf8_strlen(const c8 *src)
Gets the number of Unicode characters in a null-terminated UTF-8 string, not including the null terminator.
-
constexpr usize utf8_index(const c8 *str, usize n)
Gets the index of the first UTF-8 character for the specified Unicode character.
-
usize utf8_encode_char(c8 *dst, c32 ch)
Encodes the Unicode character into 1~6 UTF-8 characters.
-
c32 utf8_decode_char(const c8 *str)
Decodes one Unicode character from 1~6 UTF-8 characters.
-
constexpr usize utf16_charspan(c32 ch)
Gets the number of UTF-16 characters needed to store the Unicode char in UTF-16 encoding.
-
constexpr usize utf16_charlen(c16 ch)
Gets the number of UTF-16 characters the Unicode character takes from the first UTF-16 character.
-
constexpr usize utf16_charlen(const c16 *src)
Gets the number of UTF-16 characters the Unicode character takes from the first UTF-16 character.
-
constexpr usize utf16_strlen(const c16 *src)
Gets the number of Unicode characters in a null-terminated UTF-16 string, not including the null terminator.
-
constexpr usize utf16_index(const c16 *str, usize n)
Gets the index of the first UTF-16 character for the specified Unicode character.
-
usize utf16_encode_char(c16 *dst, c32 ch)
Encodes the Unicode character into 1~2 UTF-16 characters using platform-native endian.
-
c32 utf16_decode_char(const c16 *str)
Decodes one Unicode character from 1~2 UTF-16 characters.
-
usize utf16_to_utf8(c8 dst, usize dst_max_chars, const c16 src, usize src_chars=USIZE_MAX)
Converts a UTF-16 string to UTF-8 string.
-
usize utf16_to_utf8_len(const c16 *src, usize src_chars=USIZE_MAX)
Determines the length of the corresponding UTF-8 string for a UTF-16 string, not include the null-terminator.
-
usize utf8_to_utf16(c16 dst, usize dst_max_chars, const c8 src, usize src_chars=USIZE_MAX)
Converts a UTF-8 string to UTF-16 string.
-
usize utf8_to_utf16_len(const c8 *src, usize src_chars=USIZE_MAX)
Determines the length of the corresponding UTF-16 string for a UTF-8 string, not include the null-terminator.