19 struct Utf8 *
this = malloc(
sizeof(
struct Utf8));
26 size_t length = strlen(
locale) + 1;
28 this->locale = malloc(
sizeof(
char) * length);
30 strcpy(this->locale,
locale);
36 this->oldLocale = malloc(
sizeof(
char) * oldLength);
57 size_t wcharLength = wcslen(wchars);
58 size_t charsLength = wcharLength * 4;
60 char *chars = malloc(
sizeof(
char) * charsLength);
67 mbstate_t convertState;
68 memset(&convertState, 0,
sizeof(convertState));
70 wcsrtombs(chars, &wchars, charsLength, &convertState);
72 if (EILSEQ == errno) {
82 size_t charsLength = strlen(chars) + 1;
84 size_t wcharLength = charsLength;
86 wchar_t *wchars = malloc(
sizeof(
wchar_t) * wcharLength);
93 mbstate_t convertState;
94 memset(&convertState, 0,
sizeof(convertState));
96 mbsrtowcs(wchars, &chars, wcharLength, &convertState);
98 if (EILSEQ == errno || EINVAL == errno) {
108 size_t charsLength = strlen(chars) + 1;
110 size_t wcharLength = charsLength;
113 memset(&state, 0,
sizeof(state));
117 size_t count = mbsrtowcs(wchars, &chars, wcharLength, &state);
119 if (EILSEQ == errno || EINVAL == errno) {
struct Utf8 * Utf8_construct(char *locale, int *error)
struct Utf8 * Utf8_destruct(struct Utf8 *this)
size_t Utf8_countCodes(struct Utf8 *this, const char *chars, int *error)
char * Utf8_encode(struct Utf8 *this, const wchar_t *wchars, int *error)
wchar_t * Utf8_decode(struct Utf8 *this, const char *chars, int *error)
#define ERROR_STRING_NOT_CONVERTED