[Interest] unexpected result from QString::compare
Hamish Moffatt
hamish at risingsoftware.com
Fri May 8 08:27:14 CEST 2020
I'm trying to sort a list of strings where umlauts are involved, and not
getting the answer I expect from QString::compare(). My sample code is:
auto a = QStringLiteral("Äbc");
auto b = QStringLiteral("BCD");
auto c = a.compare(b);
qDebug() << a << b << c;
This produces the output:
"Äbc" "BCD" 130
which indicates that Äbc should be sorted after "BCD".
I get the same result when I load the strings through QTranslator so I
don't believe there's any editor/encoding issue going on.
I seem to get the right result when I let QListWidget sort the items for
me though.
What am I missing?
thanks,
Hamish
More information about the Interest
mailing list