Quantcast
Channel: QtWebEngine
Viewing all articles
Browse latest Browse all 13965

What's the best way of creating a QString from a wchar_t array in Windows?

$
0
0
In the Windows API, wchar_t arrays are encoded in UTF-16. QString::fromWCharArray() is according to the documentation assuming UCS-2 if the size of a wchar_t is 2 bytes. QString::fromStdWString() on the other hand assumes UTF-16 if the size of a wchar_t is 2 bytes. I don’t understand why Qt makes different assumptions for these two functions. Then we have QString::fromUtf16(). With a cast from (const wchar_t *) to (const ushort *) this seems to be a good candidate. However, the documentation points out that this function is slow and tells us to use QString(const QChar *, int) or QString(const QChar *) if possible. Is it possible to use these constructors with a wchar_t array? Bottom line: What’s the best way of creating a QString from a wchar_t array in Windows?

Viewing all articles
Browse latest Browse all 13965

Trending Articles