31 #ifndef _UTF8REWIND_H_
32 #define _UTF8REWIND_H_
40 #define UTF8_ERR_INVALID_CHARACTER (-1)
41 #define UTF8_ERR_INVALID_DATA (-2)
42 #define UTF8_ERR_NOT_ENOUGH_SPACE (-3)
43 #define UTF8_ERR_OUT_OF_RANGE (-4)
44 #define UTF8_ERR_UNHANDLED_SURROGATE_PAIR (-5)
45 #define UTF8_ERR_UNMATCHED_HIGH_SURROGATE_PAIR (-6)
46 #define UTF8_ERR_UNMATCHED_LOW_SURROGATE_PAIR (-7)
48 #if defined(__cplusplus)
128 int utf8encode(unicode_t codepoint,
char* target,
size_t targetSize);
178 int utf8convertucs2(ucs2_t codepoint,
char* target,
size_t targetSize);
231 int wctoutf8(
const wchar_t* input,
size_t inputSize,
char* target,
size_t targetSize);
276 int utf8decode(
const char* text, unicode_t* result);
308 int utf8towc(
const char* input,
size_t inputSize,
wchar_t* target,
size_t targetSize);
344 const char*
utf8seek(
const char* text,
const char* textStart, off_t offset,
int direction);
346 #if defined(__cplusplus)
int utf8decode(const char *text, unicode_t *result)
Decode a UTF-8 encoded codepoint to a Unicode codepoint.
int utf8charvalid(char encodedCharacter)
Check if a character is valid according to UTF-8 encoding.
int utf8convertucs2(ucs2_t codepoint, char *target, size_t targetSize)
Convert a UCS-2 codepoint to UTF-8.
unsigned int unicode_t
Definition: utf8rewind.h:52
int utf8len(const char *text)
Get the length in codepoints of a UTF-8 encoded string.
int wctoutf8(const wchar_t *input, size_t inputSize, char *target, size_t targetSize)
Convert a UTF-16 encoded string to UTF-8.
const char * utf8seek(const char *text, const char *textStart, off_t offset, int direction)
Seek into a UTF-8 encoded string.
int utf8charlen(char encodedCharacter)
Returns the length in bytes of the encoded character.
int utf8towc(const char *input, size_t inputSize, wchar_t *target, size_t targetSize)
Convert a UTF-8 encoded string to UTF-16.
unsigned short ucs2_t
Definition: utf8rewind.h:53
unsigned short utf16_t
Definition: utf8rewind.h:54
int utf8encode(unicode_t codepoint, char *target, size_t targetSize)
Encode a Unicode codepoint to UTF-8.