From kde-devel Fri May 08 00:32:42 2009 From: Peter Penz Date: Fri, 08 May 2009 00:32:42 +0000 To: kde-devel Subject: QString::localeAwareCompare() in KDE Message-Id: <200905080232.42465.peter.penz () gmx ! at> X-MARC-Message: https://marc.info/?l=kde-devel&m=124174284926086 Hi, I just tried to fix https://bugs.kde.org/show_bug.cgi?id=191865, where the strings are sorted in a wrong way in Dolphin like this: E & G E & J Em & M E & S instead of E & G E & J E & S Em & M I wrote a unit test in kdelibs/kdecore/tests/kstringhandlertest, which successfully passes this test: QCOMPARE(KStringHandler::naturalCompare("E & S", "Em & M", Qt::CaseSensitive), -1); -> "E & S" should be sorted _before_ "Em & M". Now when invoking KStringHandler::naturalCompare("E & S", "Em & M", Qt::CaseSensitive) in the context of Dolphin, it will return +1 instead of -1. I tracked down the problem to QString::localeAwareCompare(), which is used in KStringHandler::naturalCompare(). When replacing QString::localeAwareCompare(a, b) by a.compare(b) the strings above are sorted correctly, however obviously the capability of locale aware comparing is lost... My guess is that in the context of a KDE application a different locale- mapping-table is used as when executing the unit test. Is somebody familiar with this topic and knows how I can convince the unit test to run with the same locale settings as a KDE application? I tried QLocale::setDefault(...) but the unit test always passes correctly... Thanks! Peter >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<