I have a UTF-16LE string 'TEST' and its hexdump as below
feff 0074 0065 0073 0074 000a
If I convert this string to UTF-8 using the command iconv on bash, then it is getting converted without any issues.
6574 7473 000a
But, If I do the same this with my C program, then as soon as 0x00 is encountered with the character 'T', it seems that iconv function treats it as a null termination even tough I have specified the string length as 12 (including bom and null termination).
65 000a
Below is the code which I am testing with. However If i convert wide char string with any size (just without 0x00 bytes in between) would return me correct output.
char *cOutput; // Output buffer with more enough size required
size_t tOutput;
char *cInput; // string wide characters
size_t tInput;
iconv_t cd;
........
cd = iconv_open("UTF8//TRANSLIT", "UTF-16LE");
iconv(cd, &cInput, &tInput, &cOutput, &tOutput);
Is there any solution for this problem or if I am doing something wrong? Any input will be appreciated.