[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    QString::localeAwareCompare() in KDE
From:       Peter Penz <peter.penz () gmx ! at>
Date:       2009-05-08 0:32:42
Message-ID: 200905080232.42465.peter.penz () gmx ! at
[Download RAW message or body]

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 <<
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic