Use iconv API in C
- by Constantin
I try to convert a sjis string to utf-8 using the iconv API. I compiled it already succesfully, but the output isn't what I expected.
My code:
void convertUtf8ToSjis(char* utf8, char* sjis){
iconv_t icd;
int index = 0;
char *p_src, *p_dst;
size_t n_src, n_dst;
icd = iconv_open("Shift_JIS", "UTF-8");
int c;
p_src = utf8;
p_dst = sjis;
n_src = strlen(utf8);
n_dst = 32; // my sjis string size
iconv(icd, &p_src, &n_src, &p_dst, &n_dst);
iconv_close(icd);
}
I got only random numbers. Any ideas?
Edit:
My input is
char utf8[] = "\xe4\xba\x9c"; //?
And output should be:
0x88 0x9F
But is in fact:
0x30 0x00 0x00 0x31 0x00 ...