31 #ifndef _UTF8REWIND_H_
32 #define _UTF8REWIND_H_
42 #define UTF8_ERR_INVALID_DATA (-1)
43 #define UTF8_ERR_NOT_ENOUGH_SPACE (-2)
44 #define UTF8_ERR_UNMATCHED_HIGH_SURROGATE_PAIR (-3)
45 #define UTF8_ERR_UNMATCHED_LOW_SURROGATE_PAIR (-4)
50 #ifndef UTF8_WCHAR_SIZE
51 #if (__SIZEOF_WCHAR_T__ == 4) || (WCHAR_MAX > UINT16_MAX) || (__WCHAR_MAX__ > UINT16_MAX)
52 #define UTF8_WCHAR_SIZE (4)
54 #define UTF8_WCHAR_SIZE (2)
58 #if (UTF8_WCHAR_SIZE == 4)
59 #define UTF8_WCHAR_UTF32 (1)
60 #elif (UTF8_WCHAR_SIZE == 2)
61 #define UTF8_WCHAR_UTF16 (1)
63 #error Invalid size for wchar_t type.
68 #if defined(__cplusplus)
91 size_t utf8len(
const char* text);
133 size_t utf16toutf8(
const utf16_t* input,
size_t inputSize,
char* target,
size_t targetSize, int32_t* errors);
193 size_t utf32toutf8(
const unicode_t* input,
size_t inputSize,
char* target,
size_t targetSize, int32_t* errors);
252 size_t widetoutf8(
const wchar_t* input,
size_t inputSize,
char* target,
size_t targetSize, int32_t* errors);
295 size_t utf8toutf16(
const char* input,
size_t inputSize, utf16_t* target,
size_t targetSize, int32_t* errors);
338 size_t utf8toutf32(
const char* input,
size_t inputSize, unicode_t* target,
size_t targetSize, int32_t* errors);
407 size_t utf8towide(
const char* input,
size_t inputSize,
wchar_t* target,
size_t targetSize, int32_t* errors);
458 const char*
utf8seek(
const char* text,
const char* textStart, off_t offset,
int direction);
460 #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 utf8len(const char *text)
Get the length in codepoints of a UTF-8 encoded string.
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.
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:72
uint32_t unicode_t
Definition: utf8rewind.h:73
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.