XUtf8Error
typedef enum XUtf8Error{
X_UTF8_OK=0,
X_UTF8_ERR_EOF=-1,
X_UTF8_ERR_INVALID=-2,
X_UTF8_ERR_OVERLONG=-3,
X_UTF8_ERR_RANGE=-4
}XUtf8Error;
typedef enum XUtf8Error{
X_UTF8_OK=0,
X_UTF8_ERR_EOF=-1,
X_UTF8_ERR_INVALID=-2,
X_UTF8_ERR_OVERLONG=-3,
X_UTF8_ERR_RANGE=-4
}XUtf8Error;
Returns the expected byte length for a UTF-8 starter byte.
X_STRING_API int32_t x_utf8_codepoint_length(unsigned char first_byte);
unsigned char first_byte1..4 for a valid starter byte; negative error code if invalid.
Returns the number of UTF-8 bytes required to encode a codepoint.
X_STRING_API uint32_t x_utf8_codepoint_size(uint32_t codepoint);
uint32_t codepointNumber of UTF-8 bytes required, or 0 if the codepoint is invalid.
Decodes a single UTF-8 codepoint from the specified byte span.
X_STRING_API int32_t x_utf8_decode(
const char *ptr,
const char *end,
size_t *out_len
);
const char *ptrconst char *endsize_t *out_lenDecoded codepoint on success; negative X_UTF8_ERR_* on failure.
Encodes a Unicode codepoint as UTF-8.
X_STRING_API bool x_utf8_encode(
uint32_t codepoint,
char out[4],
uint32_t *out_len
);
uint32_t codepointchar out[4]uint32_t *out_lentrue if the codepoint was encoded successfully, false otherwise.
Checks whether the string contains exactly one UTF-8 codepoint.
X_STRING_API bool x_utf8_is_single_char(const char *s);
const char *sFunction-specific result.
Advances to the next UTF-8 codepoint boundary.
X_STRING_API uint32_t x_utf8_next(
char const *text,
uint32_t offset
);
char const *textuint32_t offsetByte offset of the next UTF-8 codepoint boundary.
Moves to the previous UTF-8 codepoint boundary.
X_STRING_API uint32_t x_utf8_prev(
char const *text,
uint32_t offset
);
char const *textuint32_t offsetByte offset of the previous UTF-8 codepoint boundary.
Compares two null-terminated UTF-8 strings.
X_STRING_API int32_t x_utf8_strcmp(
const char *a,
const char *b
);
const char *aconst char *bNegative, zero, or positive according to lexicographic order.
Returns the number of UTF-8 codepoints in a null-terminated string.
X_STRING_API size_t x_utf8_strlen(const char *utf8);
const char *utf8Number of UTF-8 codepoints.
Converts ASCII letters to lower case; leaves multibyte UTF-8 unchanged.
X_STRING_API char * x_utf8_tolower(
char *dest,
const char *src
);
char *destconst char *srcFunction-specific result.
Converts ASCII letters to upper case; leaves multibyte UTF-8 unchanged.
X_STRING_API char * x_utf8_toupper(
char *dest,
const char *src
);
char *destconst char *srcFunction-specific result.