D
Daniel Luis dos Santos
Hello,
I am trying to make a function that converts WCHAR_T strings to UTF-8.
After experimenting for a while, found out that I can only convert
standard ASCII chars. When I put a vowel with an accent (for example) I
always get a EILSEQ in errno. I am trying to convert using the
following test function :
void convTest() {
wchar_t *str = L"a ºtring";
char *inBuf = (char*)str;
size_t inBufSize = sizeof(wchar_t)*wcslen(str);
char *outBuf = (char*)malloc(1024);
size_t outBufAvailSize = sizeof(char)*1024;
iconv_t ds = iconv_open("UTF-8", "WCHAR_T");
size_t converted = iconv(ds, &inBuf, &inBufSize, &outBuf, &outBufAvailSize);
if (converted == (size_t)-1)
if (errno == EILSEQ)
printf("invalid char sequence");
else if (errno == EINVAL)
printf("incomplete input");
else if (errno == E2BIG)
printf("not enough space");
}
The º character causes an EILSEQ. I am in portugal with a portuguese keyboard.
Help !
I am trying to make a function that converts WCHAR_T strings to UTF-8.
After experimenting for a while, found out that I can only convert
standard ASCII chars. When I put a vowel with an accent (for example) I
always get a EILSEQ in errno. I am trying to convert using the
following test function :
void convTest() {
wchar_t *str = L"a ºtring";
char *inBuf = (char*)str;
size_t inBufSize = sizeof(wchar_t)*wcslen(str);
char *outBuf = (char*)malloc(1024);
size_t outBufAvailSize = sizeof(char)*1024;
iconv_t ds = iconv_open("UTF-8", "WCHAR_T");
size_t converted = iconv(ds, &inBuf, &inBufSize, &outBuf, &outBufAvailSize);
if (converted == (size_t)-1)
if (errno == EILSEQ)
printf("invalid char sequence");
else if (errno == EINVAL)
printf("incomplete input");
else if (errno == E2BIG)
printf("not enough space");
}
The º character causes an EILSEQ. I am in portugal with a portuguese keyboard.
Help !