Details
-
Bug
-
Resolution: Cannot Reproduce
-
Not Evaluated
-
None
-
4.8.5
-
None
-
Gentoo, x86-64
Qt version 4.8.5
GCC version 4.7.3
Description
I was playing around with some string processing code and ran into a rather frustrating problem. Qt 4.x doesn't seem to handle Unicode properly. Consider the following code snippets:
QString s; s.append(QChar(0xD801)).append(QChar(0xDC80)); qDebug() << s;
I expect that this will print out a string containing the Unicode codepoint: 0x10480. It does not. I wanted to find out if the problem was in QString or QChar, so I also tried this code:
quint32 cp[] = { 0x10480 }; s = QString::fromUcs4(cp, 1); qDebug() << s;
This also failed to print the expected string.
It is worth noting that both of these snippets do work on Qt 5.1, but fails to work correctly with 4.8.
At first, I thought it was a problem with surrogates. But even this snippet won't display the expected string:
QString s; s.append(QChar(0x124B)); qDebug() << s;
I suppose it's possible that this is an environment issue. But I don't know of any compilation flags for Qt which would effectively stop Unicode support from working correctly.