31 #ifndef _UTF8REWIND_H_
32 #define _UTF8REWIND_H_
42 #define UTF8_ERR_INVALID_CHARACTER (-1)
43 #define UTF8_ERR_INVALID_DATA (-2)
44 #define UTF8_ERR_NOT_ENOUGH_SPACE (-3)
45 #define UTF8_ERR_OUT_OF_RANGE (-4)
46 #define UTF8_ERR_UNHANDLED_SURROGATE_PAIR (-5)
47 #define UTF8_ERR_UNMATCHED_HIGH_SURROGATE_PAIR (-6)
48 #define UTF8_ERR_UNMATCHED_LOW_SURROGATE_PAIR (-7)
53 #ifndef UTF8_WCHAR_SIZE
54 #if (__SIZEOF_WCHAR_T__ == 4) || (WCHAR_MAX > UINT16_MAX) || (__WCHAR_MAX__ > UINT16_MAX)
55 #define UTF8_WCHAR_SIZE (4)
57 #define UTF8_WCHAR_SIZE (2)
61 #if (UTF8_WCHAR_SIZE == 4)
62 #define UTF8_WCHAR_UTF32 (1)
63 #elif (UTF8_WCHAR_SIZE == 2)
64 #define UTF8_WCHAR_UTF16 (1)
66 #error Invalid size for wchar_t type.
71 #if defined(__cplusplus)
118 size_t utf8len(
const char* text);
165 size_t utf16toutf8(
const utf16_t* input,
size_t inputSize,
char* target,
size_t targetSize, int32_t* errors);
230 size_t utf32toutf8(
const unicode_t* input,
size_t inputSize,
char* target,
size_t targetSize, int32_t* errors);
294 size_t widetoutf8(
const wchar_t* input,
size_t inputSize,
char* target,
size_t targetSize, int32_t* errors);
337 size_t utf8toutf16(
const char* input,
size_t inputSize, utf16_t* target,
size_t targetSize, int32_t* errors);
380 size_t utf8toutf32(
const char* input,
size_t inputSize, unicode_t* target,
size_t targetSize, int32_t* errors);
450 size_t utf8towide(
const char* input,
size_t inputSize,
wchar_t* target,
size_t targetSize, int32_t* errors);
501 const char*
utf8seek(
const char* text,
const char* textStart, off_t offset,
int direction);
503 #if defined(__cplusplus)
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.
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.
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.
size_t utf8charlen(char encodedCharacter)
Returns the length in bytes of the encoded character.
size_t utf8len(const char *text)
Get the length in codepoints of a UTF-8 encoded string.
int8_t utf8charvalid(char encodedCharacter)
Check if a character is valid according to UTF-8 encoding.
const char * utf8seek(const char *text, const char *textStart, off_t offset, int direction)
Seek into a UTF-8 encoded string.
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.
uint16_t ucs2_t
Definition: utf8rewind.h:76
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.
uint16_t utf16_t
Definition: utf8rewind.h:77
uint32_t unicode_t
Definition: utf8rewind.h:75
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.