Originally posted by MadCatX
View Post
Originally posted by MadCatX
Originally posted by MadCatX
View Post
You don't seem to get what I try to point out: QString does not handle UTF-16. What it handles is UCS-2. The Qt documentation tries to get away with saying "each QChar corresponds to one UTF-16 code unit". This is only a 16 bit unsigned value - not the same as a "Code Point".
If you compare the equivalent types, the guarantees of Qt are no better than the STL. Do not compare char with QChar. Furthermore, the STL provides wchar_t that does not exist on Qt. Strings from that type handle UTF correctly. You correctly point out that wchar_t is not 100% multiplatform, but with the STL it's easy to define a type that is: std::basic_string<u32char_t>. You'll struggle to get that with Qt.
Let me show you where QString falls flat:
Code:
"😎 = \U0001F60E is B-)"
See for yourself with the following code:
Code:
#include <iostream> #include <QString> #include <string> int main() { std::wstring const wstr{L"😎 = \U0001F60E is B-)"}; QString qstr(QString::fromStdWString(wstr)); std::cout << "wstring size:" << wstr.size() << " QString size:" << qstr.length() << "\n"; }
Another point of annoyance: From Qt5 until somewhere in the middle of Qt5, the standard binary installation of Qt included a version of libicu. Initially this lead me to think that QString handles UTF correctly. But I had to learn the hard way that it does not despite including the resources to do it correctly.
Comment