[Interest] Filling QString from raw UTF16 data
Konstantin Tokarev
annulen at yandex.ru
Sat Aug 11 18:51:30 CEST 2012
Hi all,
I'd like to use SCSU encoding from ICU library in my Qt application. Here is a code of my decoding function:
QString result;
result.resize(maxSize); // maxSize is guaranteed to be >= size
const int size = ucnv_toUChars(m_converter, const_cast<ushort *>(result.utf16()), maxSize, a, inSize, &status);
result.resize(size);
return result;
(ucnv_toUChars fills array in second argument with UTF16 string and returns its size)
Is it safe to use return value of QString::utf16() this way in this context (QString is always created on stack locally)?
I don't use QString::fromUtf16 because I'd like to avoid data copying.
--
Regards,
Konstantin
More information about the Interest
mailing list