26 #ifndef _UTF8REWIND_H_
27 #define _UTF8REWIND_H_
51 #define UTF8_VERSION_MAKE(_major, _minor, _bugfix) \
52 ((_major) * 10000) + ((_minor) * 100) + (_bugfix)
58 #define UTF8_VERSION_MAJOR 1
64 #define UTF8_VERSION_MINOR 3
70 #define UTF8_VERSION_BUGFIX 0
76 #define UTF8_VERSION \
77 UTF8_VERSION_MAKE(UTF8_VERSION_MAJOR, UTF8_VERSION_MINOR, UTF8_VERSION_BUGFIX)
83 #define UTF8_VERSION_STRING "1.3.0"
89 #define UTF8_VERSION_GUARD(_major, _minor, _bugfix) \
90 (UTF8_VERSION >= UTF8_VERSION_MAKE(_major, _minor, _bugfix))
105 #define UTF8_ERR_NONE (0)
111 #define UTF8_ERR_INVALID_DATA (-1)
117 #define UTF8_ERR_INVALID_FLAG (-2)
123 #define UTF8_ERR_NOT_ENOUGH_SPACE (-3)
129 #define UTF8_ERR_OVERLAPPING_PARAMETERS (-4)
139 #define UTF8_NORMALIZE_COMPOSE 0x00000001
145 #define UTF8_NORMALIZE_DECOMPOSE 0x00000002
151 #define UTF8_NORMALIZE_COMPATIBILITY 0x00000004
157 #define UTF8_NORMALIZATION_RESULT_YES (0)
163 #define UTF8_NORMALIZATION_RESULT_MAYBE (1)
169 #define UTF8_NORMALIZATION_RESULT_NO (2)
184 #ifndef UTF8_WCHAR_SIZE
185 #if (__SIZEOF_WCHAR_T__ == 4) || (WCHAR_MAX > UINT16_MAX) || (__WCHAR_MAX__ > UINT16_MAX)
186 #define UTF8_WCHAR_SIZE (4)
188 #define UTF8_WCHAR_SIZE (2)
192 #if (UTF8_WCHAR_SIZE == 4)
197 #define UTF8_WCHAR_UTF32 (1)
198 #elif (UTF8_WCHAR_SIZE == 2)
203 #define UTF8_WCHAR_UTF16 (1)
205 #error Invalid size for wchar_t type.
215 #define UTF8_API extern "C"
424 UTF8_API size_t widetoutf8(
const wchar_t* input,
size_t inputSize,
char* target,
size_t targetSize, int32_t* errors);
592 UTF8_API size_t utf8towide(
const char* input,
size_t inputSize,
wchar_t* target,
size_t targetSize, int32_t* errors);
645 UTF8_API const char*
utf8seek(
const char* text,
size_t textSize,
const char* textStart, off_t offset,
int direction);
733 UTF8_API size_t utf8toupper(
const char* input,
size_t inputSize,
char* target,
size_t targetSize, int32_t* errors);
826 UTF8_API size_t utf8tolower(
const char* input,
size_t inputSize,
char* target,
size_t targetSize, int32_t* errors);
913 UTF8_API size_t utf8totitle(
const char* input,
size_t inputSize,
char* target,
size_t targetSize, int32_t* errors);
1131 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
UTF-32 encoded code point.
Definition: utf8rewind.h:235
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:217
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 code point.
Definition: utf8rewind.h:229
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 size_t utf8len(const char *text)
Get the length in code points 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.
UTF8_API const char * utf8seek(const char *text, size_t textSize, const char *textStart, off_t offset, int direction)
Seek into a UTF-8 encoded string.