[Interest] unexpected result from QString::compare
Fabrice Mousset | GEOCEPT GmbH
fabrice.mousset at geocept.com
Fri May 8 09:13:31 CEST 2020
Perhaps you should use QString::localeAwareCompare() ?
BR
Fabrice
> -----Ursprüngliche Nachricht-----
> Von: Interest <interest-bounces at qt-project.org> Im Auftrag von Hamish
> Moffatt
> Gesendet: Freitag, 8. Mai 2020 08:27
> An: Qt Interest <interest at qt-project.org>
> Betreff: [Interest] unexpected result from QString::compare
>
> 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
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> https://lists.qt-project.org/listinfo/interest
More information about the Interest
mailing list