26 #ifndef _UTF8REWIND_H_
27 #define _UTF8REWIND_H_
49 #define UTF8_ERR_NONE (0)
55 #define UTF8_ERR_INVALID_DATA (-1)
61 #define UTF8_ERR_INVALID_FLAG (-2)
67 #define UTF8_ERR_NOT_ENOUGH_SPACE (-3)
73 #define UTF8_ERR_OVERLAPPING_PARAMETERS (-4)
83 #define UTF8_NORMALIZE_COMPOSE 0x00000001
89 #define UTF8_NORMALIZE_DECOMPOSE 0x00000002
95 #define UTF8_NORMALIZE_COMPATIBILITY 0x00000004
101 #define UTF8_NORMALIZATION_RESULT_YES (0)
107 #define UTF8_NORMALIZATION_RESULT_MAYBE (1)
113 #define UTF8_NORMALIZATION_RESULT_NO (2)
127 #ifndef UTF8_WCHAR_SIZE
128 #if (__SIZEOF_WCHAR_T__ == 4) || (WCHAR_MAX > UINT16_MAX) || (__WCHAR_MAX__ > UINT16_MAX)
129 #define UTF8_WCHAR_SIZE (4)
131 #define UTF8_WCHAR_SIZE (2)
135 #if (UTF8_WCHAR_SIZE == 4)
140 #define UTF8_WCHAR_UTF32 (1)
141 #elif (UTF8_WCHAR_SIZE == 2)
146 #define UTF8_WCHAR_UTF16 (1)
148 #error Invalid size for wchar_t type.
158 #define UTF8_API extern "C"
370 UTF8_API size_t widetoutf8(
const wchar_t* input,
size_t inputSize,
char* target,
size_t targetSize, int32_t* errors);
535 UTF8_API size_t utf8towide(
const char* input,
size_t inputSize,
wchar_t* target,
size_t targetSize, int32_t* errors);
587 UTF8_API const char*
utf8seek(
const char* text,
const char* textStart, off_t offset,
int direction);
665 UTF8_API size_t utf8toupper(
const char* input,
size_t inputSize,
char* target,
size_t targetSize, int32_t* errors);
748 UTF8_API size_t utf8tolower(
const char* input,
size_t inputSize,
char* target,
size_t targetSize, int32_t* errors);
825 UTF8_API size_t utf8totitle(
const char* input,
size_t inputSize,
char* target,
size_t targetSize, int32_t* errors);
1043 UTF8_API size_t utf8normalize(
const char* input,
size_t inputSize,
char* target,
size_t targetSize,
size_t flags, int32_t* errors);
uint32_t unicode_t
Unicode codepoint.
Definition: utf8rewind.h:178
UTF8_API size_t utf8totitle(const char *input, size_t inputSize, char *target, size_t targetSize, int32_t *errors)
Convert UTF-8 encoded text to titlecase.
UTF8_API size_t utf8normalize(const char *input, size_t inputSize, char *target, size_t targetSize, size_t flags, int32_t *errors)
Normalize a string to the specified Unicode Normalization Form.
#define UTF8_API
Calling convention for public functions.
Definition: utf8rewind.h:160
UTF8_API size_t utf8toutf32(const char *input, size_t inputSize, unicode_t *target, size_t targetSize, int32_t *errors)
Convert a UTF-8 encoded string to a UTF-32 encoded string.
UTF8_API size_t utf8toupper(const char *input, size_t inputSize, char *target, size_t targetSize, int32_t *errors)
Convert UTF-8 encoded text to uppercase.
uint16_t utf16_t
UTF-16 encoded codepoint.
Definition: utf8rewind.h:172
UTF8_API size_t utf16toutf8(const utf16_t *input, size_t inputSize, char *target, size_t targetSize, int32_t *errors)
Convert a UTF-16 encoded string to a UTF-8 encoded string.
UTF8_API size_t utf8toutf16(const char *input, size_t inputSize, utf16_t *target, size_t targetSize, int32_t *errors)
Convert a UTF-8 encoded string to a UTF-16 encoded string.
UTF8_API size_t utf8towide(const char *input, size_t inputSize, wchar_t *target, size_t targetSize, int32_t *errors)
Convert a UTF-8 encoded string to a wide string.
UTF8_API uint8_t utf8isnormalized(const char *input, size_t inputSize, size_t flags, size_t *offset)
Check if a string is stable in the specified Unicode Normalization Form.
UTF8_API size_t utf8tolower(const char *input, size_t inputSize, char *target, size_t targetSize, int32_t *errors)
Convert UTF-8 encoded text to lowercase.
UTF8_API const char * utf8seek(const char *text, const char *textStart, off_t offset, int direction)
Seek into a UTF-8 encoded string.
UTF8_API size_t utf8len(const char *text)
Get the length in codepoints of a UTF-8 encoded string.
UTF8_API size_t utf32toutf8(const unicode_t *input, size_t inputSize, char *target, size_t targetSize, int32_t *errors)
Convert a UTF-32 encoded string to a UTF-8 encoded string.
UTF8_API size_t widetoutf8(const wchar_t *input, size_t inputSize, char *target, size_t targetSize, int32_t *errors)
Convert a wide string to a UTF-8 encoded string.