Details
-
Bug
-
Resolution: Duplicate
-
P2: Important
-
None
-
6.4.0
-
None
Description
We experienced a problem where QCollatorSortKey gave the wrong sort order under Windows. So we downloaded the 6.4 source code and found the instantiation of QCollatorSortKey in file corelib/text/qcollator_win.cpp at line 92.
The code seems to call Windows NLS function LCMapStringW with flag LCMAP_SORTKEY to generate a sort key which it stores in a QString.
The documentation for LCMapStringW, however, states that:
- The sort key is stored in the buffer and treated as an opaque array of bytes. The stored values can include embedded 0 bytes at any position.
(https://learn.microsoft.com/en-us/windows/win32/api/winnls/nf-winnls-lcmapstringw)
As a result, QCollatorSortKey::compare() may get the wrong result when it uses QString::compare() to compare the two sort keys. It would be better to store the sort keys in e.g. a QByteArray.
QTBUG-108756 is probably a symptom of this bug but I made a new one as numeric mode is not the only case where this bug hits.
Kind Regards
Bjørn Thirud
I attached a unit test that we used to explore this issue.
Attachments
Issue Links
- relates to
-
QTBUG-88704 QCollatorSortKey is not working properly without ICU support
-
- In Progress
-