[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: QString::localeAwareCompare() in KDE
From: Albert Astals Cid <aacid () kde ! org>
Date: 2009-05-08 21:43:50
Message-ID: 200905082343.52199.aacid () kde ! org
[Download RAW message or body]
A Divendres, 8 de maig de 2009, Thiago Macieira va escriure:
> Peter Penz wrote:
> >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...
>
> This is localeAwareCompare for Unix (which aren't Macs):
>
> int delta = strcoll(toLocal8Bit_helper(data1, length1),
> toLocal8Bit_helper(data2, length2));
>
> if (delta == 0)
> delta = ucstrcmp(data1, length1, data2, length2);
> return delta;
>
> As you can see, it's basically calling strcoll(3), which is a C library
> function. Setting the default QLocale will have no effect: you have to set
> the C library's locale, via setlocale(3).
>
> In any case, the sorting you find weird is coming from glibc. There's
> little we can do.
Another weird consequence of using strcoll
http://sources.redhat.com/ml/libc-alpha/2004-01/msg00145.html
unit.cpp < unitdescriptor.cpp
unit.h > unitdescriptor.cpp
That doesn't make sense at all but well libc/locale people is a bit obtuse as
we all know.
Albert
>> 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