Bug 211531 - Dolphin is not honouring the LC_COLLATE setting
Summary: Dolphin is not honouring the LC_COLLATE setting
Alias: None
Product: dolphin
Classification: Applications
Component: general (show other bugs)
Version: 2.1
Platform: Chakra Linux
: NOR normal with 165 votes (vote)
Target Milestone: ---
Assignee: Dolphin Bug Assignee
Depends on:
Reported: 2009-10-23 13:20 UTC by EnzoR
Modified: 2023-02-19 19:30 UTC (History)
14 users (show)

See Also:
Latest Commit:
Version Fixed In:

C locale working properly (49.13 KB, image/png)
2016-11-28 00:23 UTC, Konstantinos Smanis
C locale working properly on some weird file names (49.31 KB, image/png)
2016-11-28 00:25 UTC, Konstantinos Smanis
en_US.utf8 locale breaking on some weird file names (48.92 KB, image/png)
2016-11-28 00:26 UTC, Konstantinos Smanis
Proposed patch (4.46 KB, patch)
2016-11-28 18:13 UTC, Konstantinos Smanis
Revised patch (3.56 KB, patch)
2016-12-04 21:42 UTC, Konstantinos Smanis
Alphabetical order, case sensitive (104.16 KB, image/png)
2022-04-07 09:45 UTC, EnzoR

Note You need to log in before you can comment on or make changes to this bug.
Description EnzoR 2009-10-23 13:20:16 UTC
Version:           1.3 (using KDE 4.3.1)
OS:                Linux
Installed from:    Fedora RPMs

Deaspite I'm running a system wide LC_COLLATE="C" setting, Dolphin is showing the file lists with case insensitive sorting, which is not "C" collation.
Comment 1 mdhirsch 2009-12-07 01:11:15 UTC
I think this is a bigger problem than Dolphin.  My mail folders in KMail are also sorted case insentively, event though I have LC_COLLATE=POSIX.

Also, konqueror is doing a case insensitive sort, just like dolphin.  It wouldn't surprise me if there were multiple places in KDE that are ignoring LC_COLLATE.
Comment 2 mdhirsch 2009-12-07 01:14:44 UTC
This is not a wishlist item.  It is 
1) a violation of spec
2) a regression from KDE 3.x
Comment 3 ray 2010-01-11 09:20:25 UTC
This has been reported as Bug 148550, 176185, 199238

------- Comment #3 From Peter Penz  2007-12-03 12:26:22 -------  
Yes, this feature is missing currently and we'll try to fix this in 4.1.
Comment 4 EnzoR 2010-01-11 10:04:43 UTC
We all users hope for a backport of this fix as we think it should not be a huge one.
Comment 5 Uqbar 2012-02-06 19:04:10 UTC
Well, as of v2.0 (KDE v4.8.0) the bug is still here.
And getting more and more annoying.
Comment 6 Jeroen van Meeuwen (Kolab Systems) 2012-08-24 16:22:31 UTC
Resetting assignee to default as per bug #305719
Comment 7 Adrián Chaves (Gallaecio) 2012-10-27 06:58:08 UTC
Steps to reproduce:

1. Open a Konsole, and run: “LC_COLLATE=C dolphin”.
2. From the new Dolphin window, go to a test folder, open the built-in terminal (F4), and run: “touch A B a b”.
3. Check how the files in Dolphin are ordered as “a A b B”.
4. In the built-in terminal, run “ls”. Check how the “ls” command succeds in showing the files ordered as “A B a b”.
Comment 8 Yichao Yu 2013-01-29 16:03:39 UTC
Seems that dolphin uses QString::compare to compare file names. So it is either QString:compare should respect the LC_COLLATE environment variable (which will probably not be acceptable since it may be considered a api breaking) or all item name sorting in any item view's (not only dolphin but also in other item views like systemsettings.) should use a different function to compare strings which will be a lot of work (but maybe either Qt or kdelibs should provide/have already provided this function?).
Comment 9 Yichao Yu 2013-01-29 16:07:44 UTC
Is that just QString::localeAwareCompare() ??
Comment 10 Jesper Saxtorph 2013-05-05 12:39:08 UTC
Would like to note this is also a problem with international characters.
I am living in Denmark and am affected by this problem with the Danish characters æ, ø and å.
In a terminal all is fine:
touch a b o p z æ ø å
Running ls correctly give: a  b  o  p  z  æ  ø  å
in dolphin (and also file dialogs from e.g. kate) the sorting will be:
a å æ b o ø p z

This is annoying but usable for people like me who understand it (and as long time habbit normally only use ascii chars for filenames), but for the average user who are not aware of it, they might not be able to find their files.
Comment 11 kazuhirokunishi 2014-02-13 04:50:33 UTC
Same issue in Japanese locale. My Dolphin version is KDE 4.11.5/Gentoo amd64. "Sort By Name" is able to handle Japanese by head letter at LANG="en_US.UTF-8" LC_COLLATE="C" environment, however Dolphin groups each Japanese character into the category A at LANG="ja_JP. UTF-8" LC_COLLATE="C" environment. Here is the screenshot http://goo.gl/18UUuT
Comment 12 Emmanuel Pescosta 2015-01-30 07:26:41 UTC
Hi everyone, 
can someone please test it with the latest Dolphin from frameworks branch? 
If not, it would be awesome if someone can test it with the next Dolphin release 15.04 (will be released in about 3 months) and give a short feedback if it works now. Thanks in advance!

Dolphin (currently only frameworks branch, because it is Qt5 only) uses QCollator [1] for sorting now.

[1] http://doc.qt.io/qt-5/qcollator.html
Comment 13 Konstantinos Smanis 2016-11-28 00:20:08 UTC
Well, not all is peachy.

The 'C' locale seems to be properly collated, but other locales (e.g. 'en_US.utf8') are not.
Comment 14 Konstantinos Smanis 2016-11-28 00:23:57 UTC
Created attachment 102485 [details]
C locale working properly

Dolphin 16.08.3
Qt 5.6.1
KF 5.28.0
Comment 15 Konstantinos Smanis 2016-11-28 00:25:55 UTC
Created attachment 102486 [details]
C locale working properly on some weird file names

Dolphin 16.08.3
Qt 5.6.1
KF 5.28.0
Comment 16 Konstantinos Smanis 2016-11-28 00:26:35 UTC
Created attachment 102487 [details]
en_US.utf8 locale breaking on some weird file names

Dolphin 16.08.3
Qt 5.6.1
KF 5.28.0
Comment 17 Konstantinos Smanis 2016-11-28 18:13:25 UTC
Created attachment 102506 [details]
Proposed patch

Seems like QCollator was only used for natural sorting for some reason, falling back to QString::compare in the other cases, i.e. C-locale collating. I will have to research this reason to make sure that we don't break anything.
Comment 18 Konstantinos Smanis 2016-12-04 21:42:22 UTC
Created attachment 102626 [details]
Revised patch

According to QtBug #17104 [1], LC_COLLATE is ignored by Qt. Something along the lines of m_collator.setLocale(QProcessEnvironment::systemEnvironment().value("LC_COLLATE")); could be used instead, although it's a tad ugly.

But then I'm hitting another bug: with LC_COLLATE=C the QCollator is properly set to collate using the C-locale but the comparisons are wrong. E.g. even QCollator(QLocale("C")).compare("A", "a"); returns 1 for me, instead of a negative value.

Of course we could fall back to QString::compare in this specific case (C-locale), but this is ugly as well. I am not gonna pursue this any further, I leave my code & research here in case anyone is interested to pick it up.

[1] https://bugreports.qt.io/browse/QTBUG-17104
Comment 19 Boian Berberov 2019-01-10 20:37:18 UTC
There is some additional information in:

https://bugreports.qt.io/browse/QTBUG-58621 (possible fix in Qt 5.12.1)



Dolphin 18.12.0, openSUSE Tumbleweed

Possibly related to bug 217814
Comment 20 EnzoR 2022-04-07 09:45:00 UTC
As of today, Dolphin is still behaving weirdly.
Dolphin version: 21.12.3
KDE Frameworks Version: 5.92.0
Qt Version: 5.15.3

I created 4 file with this command:

touch a A b B

Then I have started dolphin in that very directory with this command:

LC_COLLATE=C dolphin .

Collation is completely ignored and files are sorted as: A a B b. Directories are placed *before* files.
I then configure dolphin to use "Sorting mode: Alphabetical, case sensitive" (default is some unknown "Natural" mode) and restarted dolphin, with the very same command line.
Now dolphin displays those four files in the correct order (A B a b) while still displaying directory names *before* files.
I am attaching a screenshot to document this last use case.
Comment 21 EnzoR 2022-04-07 09:45:45 UTC
Created attachment 148015 [details]
Alphabetical order, case sensitive
Comment 22 Sergey Popov 2023-01-25 08:52:32 UTC
Affected by this issue too. Moreover, if i set LC_COLLATE to en_US(and leave other LC_* and LANG variables untouched) Dolphin SWITCHES to English! But if i set LC_COLLATE=C(still not touching other language-specific variables) - Dolphin is displayed in proper language, but natural sorting is broken