I have to go through some text and write UTF8 output according to the character patterns. I thought it\'ll be easy if I can work with the code points and get it converted to
iconv could be used I figure.
#include
iconv_t cd;
char out[7];
wchar_t in = CODE_POINT_VALUE;
size_t inlen = sizeof(in), outlen = sizeof(out);
cd = iconv_open("utf-8", "wchar_t");
iconv(cd, (char **)&in, &inl, &out, &outlen);
iconv_close(cd);
But I fear that wchar_t might not represent Unicode code points, but arbitrary values.. EDIT: I guess you can do it by simply using a Unicode source:
uint16_t in = UNICODE_POINT_VALUE;
cd = iconv_open("utf-8", "ucs-2");