From kde-devel Thu May 28 21:58:00 2009 From: =?iso-8859-1?q?Andr=E9_W=F6bbeking?= Date: Thu, 28 May 2009 21:58:00 +0000 To: kde-devel Subject: Re: QString::localeAwareCompare() in KDE Message-Id: <200905282358.00903.Woebbeking () kde ! org> X-MARC-Message: https://marc.info/?l=kde-devel&m=124354794808420 On Friday 08 May 2009, Peter Penz wrote: > [...] > > > >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. > > Thanks Thiago. Too sad that this is not directly in our hands... I'll > still try to adapt the unit test to use a setLocale(3) call to have > the same (wrong) behavior like when using it within a KDE > application. By this we have at least documented a known failure... Are you sure that this is a failure? AFAIK these are locale sorting rules also used in e.g. phone books. Have a look at http://en.wikipedia.org/wiki/Collation Cheers, André >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<