c++ - why UChar* is not working with this ICU conversion? -


when converting utf-8 iso-8859-6 code didn't work:

unicodestring ustr = unicodestring::fromutf8(stringpiece(input));  const uchar* source = ustr.getbuffer();  char target[1000]; uerrorcode status = u_zero_error; uconverter *conv; int32_t     len;  // set converter conv = ucnv_open("iso-8859-6", &status); assert(u_success(status));  // convert  len = ucnv_fromuchars(conv, target, 100, source, -1, &status); assert(u_success(status));  // close converter ucnv_close(conv);  string s(target); return s; 

images: (1,2)

however when replacing uchar* hard-coded uchar[] works well!! image : (3)

it looks you're taking difficult approach. how this:

static char const* const cp = "iso-8859-6"; unicodestring ustr = unicodestring::fromutf8(stringpiece(input)); std::vector<char> buf(ustr.length() + 1); std::vector<char>::size_type len = ustr.extract(0, ustr.length(), &buf[0], buf.size(), cp); if (len >= buf.size()) {     buf.resize(len + 1);     len = ustr.extract(0, ustr.length(), &buf[0], buf.size(), cp); } std::string ret; if (len)     ret.assign(buf.begin(), buf.begin() + len)); return ret; 

Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -