Summary: | strcoll sorting order | ||
---|---|---|---|
Product: | glibc | Reporter: | Andrzej <ndrwrdck> |
Component: | localedata | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | RESOLVED INVALID | ||
Severity: | normal | CC: | libc-locales, pasky |
Priority: | P2 | Flags: | fweimer:
security-
|
Version: | 2.13 | ||
Target Milestone: | --- | ||
Host: | Target: | ||
Build: | Last reconfirmed: |
Description
Andrzej
2012-05-01 03:42:22 UTC
Just to clarify, I run into this issue(?) when we tried to optimize sorting in our application. Our assumption was that, knowing that the first character of two strings are different, comparing just these characters is as good as comparing the whole strings, that is if 'あ' < 'a' then 'あaaa' < 'aa'. This assumption fails with the current design of strcoll. This is a bad assumption in any case because the sorting algorithm may ignore some characters in the first pass. The common The common sorting weights from iso14651_t1_common has no entry for japanese characters, so they are ignored in the first pass. The ja_JP locale sorts them after the latin characters. Marking as INVALID, thanks to Andreas for taking care to explain. Indeed, the sorting is locale-dependent and may ignore various (usually the unknown) characters. Set LC_COLLATE to POSIX if you want "programmer-friendly" sorting order. Andrzej, feel free to reopen if you have more questions. Just wanted to ask if there is any plan of adding Japanese definition to iso14651_t1_common file. The current behavior doesn't seems particularly useful. Also, the documentation issue is still valid - for a nontrivial function like this, there should be at least some hints about where to find the comparison rules or what standards does it comply with. (I'm satisfied with your explanation so I don't reopen the bug. Please feel free to reopen/reassign it if you think the above issues need to be addressed.) |