I'm trying to read some multibyte chars on mac, but the the their code page is unknown. Is there a way to read them and convert them to utf-8? the locale and region can be used, is there a way to connect them to the corresponding code page info? for example, I want to translate '\xbf\xa7' which represent chinese charactor "咖".
Now I'm using iconv to convert the charactors, but it requires the code info: my code is as below:
char src=[] ="\xbf\xa7";
char dst[100];
size_t srclen=3;
size_t dstlen=6;
char *pIn=src;
char *pOut =(char*)dst;
iconv_t conv= iconv_open("UTF-8","GBK");
iconv(conv,&pIn,&srclen, &pOut,&dstlen);
iconv_close(conv);
fprintf(stderr,"out: %s\n",dst);
Thank you!
Update: Is there a way to determine the encoding of the system? so I can use it as from code for iconv_open?