Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
6.0.0 Beta5
-
None
Description
While extending tst_QCollator to support QCollatorSortKey, I've noticed that on platforms without ICU (!QT_CONFIG(icu)) the result of QCollatorSortKey::compare is not always equal to the results of QCollator::compare.
Sample code to illustrate the problem
auto asSign = [](int compared) { return compared < 0 ? -1 : compared > 0 ? 1 : 0; }; QString str1("some str"); QString str2("some other str"); QCollator collator(/*some initialization params*/); int collatorResult = asSign(collator.compare(str1, str2)); QCollatorSortKey key1 = collator.sortKey(str1); QCollatorSortKey key2 = collator.sortKey(str2); int collatorKeyResult = asSign(key1.compare(key2));
Based on the parameters of collator (case sensitivity, numeric mode, ignore punctuation) the results of the 2 comparisons can be equal or different, which is quite confusing for me.
A real code for the test can be found in qtbase/tests/auto/corelib/text/qcollator/tst_qcollator.cpp
Good starting points are qtbase/src/corelib/text/qcollator_macx.cpp (for Mac) and qtbase/src/corelib/text/qcollator_win.cpp (for Windows)
Attachments
Issue Links
- is duplicated by
-
QTBUG-108756 QCollatorSortKey gives wrong compare result
-
- Closed
-
-
QTBUG-128170 QCollator::sortKey gives wrong sorting for numbers on Windows
-
- Closed
-
- relates to
-
QTBUG-67490 QCollatorSortKey doesn't work on macOS
-
- In Progress
-
-
QTBUG-88546 Improve QCollator testing
-
- Closed
-
-
QTBUG-112981 QCollatorSortKey bug in Windows implementation
-
- Closed
-
-
QTBUG-128170 QCollator::sortKey gives wrong sorting for numbers on Windows
-
- Closed
-
Gerrit Reviews
For Gerrit Dashboard: QTBUG-88704 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
590289,5 | QCollator/Win: use QByteArray, not QString, as the key type | dev | qt/qtbase | Status: NEW | +2 | 0 |
590290,7 | QCollator/Darwin: fix handling of UCGetCollationKey() return status | dev | qt/qtbase | Status: NEW | -1 | 0 |
590291,5 | QCollator/Darwin: implement support for sort keys for the C locale | dev | qt/qtbase | Status: NEW | +2 | +1 |