c++ - How to get string from CP866 bytes -
my program read bytes file , try convert string. head of file text in cp866.
iconv_t cd = iconv_open("utf-8","cp866"); char* iconv_in = bytes.data(); //bytes char vector char* iconv_out = (char *)malloc(counter * sizeof(char)); //counter length of bytes array (char vector) size_t iconv_in_bytes =counter; size_t iconv_out_bytes = counter; size_t ret = iconv(cd, &iconv_in, &iconv_in_bytes, &iconv_out, &iconv_out_bytes); if ((size_t) -1 == ret) { cout << "error convert"; return null; }
program ends failure (error convert). , way not simple , beautiful. there exist more simple solution?
Comments
Post a Comment