diff options
author | Lars Knoll <lars.knoll@digia.com> | 2014-03-24 16:12:20 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-06-12 10:26:07 +0200 |
commit | 81ba16cad933981f55218964a89ed1446022efba (patch) | |
tree | e77b373562a7bf9bfc86b6a92eefbd54ea4c4e1e /src/corelib/tools/qcollator_macx.cpp | |
parent | dbe6db192aa1a3e708b00a98a17636af37ceec27 (diff) |
Fix case insensitive comparisons using QCollator
In ICU the strength parameter decides whether a comparison is
case sensitive or not.
Fix mac comparison code. It can't have worked before.
Added some basic automated testing for QCollator.
Change-Id: I2646c464fd22ccd3a93c461fa3dba4bd1d4c7b4b
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Diffstat (limited to 'src/corelib/tools/qcollator_macx.cpp')
-rw-r--r-- | src/corelib/tools/qcollator_macx.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/corelib/tools/qcollator_macx.cpp b/src/corelib/tools/qcollator_macx.cpp index 8985cd4eba..877510489a 100644 --- a/src/corelib/tools/qcollator_macx.cpp +++ b/src/corelib/tools/qcollator_macx.cpp @@ -128,12 +128,15 @@ bool QCollator::ignorePunctuation() const int QCollator::compare(const QChar *s1, int len1, const QChar *s2, int len2) const { SInt32 result; - return UCCompareText(d->collator.collator, + Boolean equivalent; + UCCompareText(d->collator.collator, reinterpret_cast<const UniChar *>(s1), len1, reinterpret_cast<const UniChar *>(s2), len2, - NULL, + &equivalent, &result); - return result; + if (equivalent) + return 0; + return result < 0 ? -1 : 1; } int QCollator::compare(const QString &str1, const QString &str2) const { |