#include "qlocale_p.h"
#include "qmutex.h"
-#include "unicode/uversion.h"
-#include "unicode/ucol.h"
#include "unicode/uloc.h"
#include "unicode/ustring.h"
typedef int32_t (*Ptr_u_strToCase)(UChar *dest, int32_t destCapacity, const UChar *src, int32_t srcLength, const char *locale, UErrorCode *pErrorCode);
-bool QIcu::strcoll(const QByteArray &localeID,
- const QChar *source, int sourceLength, const QChar *target, int targetLength, int *result)
-{
- Q_ASSERT(result);
- Q_ASSERT(source);
- Q_ASSERT(target);
-
- UErrorCode icuStatus = U_ZERO_ERROR;
- UCollator *collator = ucol_open(localeID, &icuStatus);
-
- if (U_FAILURE((icuStatus)))
- return false;
-
- *result = ucol_strcoll(collator,
- reinterpret_cast<const UChar *>(source), int32_t(sourceLength),
- reinterpret_cast<const UChar *>(target), int32_t(targetLength));
-
- ucol_close(collator);
-
- return true;
-}
-
// caseFunc can either be u_strToUpper or u_strToLower
static bool qt_u_strToCase(const QString &str, QString *out, const char *localeID, Ptr_u_strToCase caseFunc)
{
namespace QIcu {
QString toUpper(const QByteArray &localeId, const QString &str, bool *ok);
QString toLower(const QByteArray &localeId, const QString &str, bool *ok);
-
- bool strcoll(const QByteArray &localeID, const QChar *source, int sourceLength, const QChar *target, int targetLength, int *result);
}
#endif
#include "qhash.h"
#include "qdebug.h"
#include "qendian.h"
+#include "qcollator_p.h"
#ifdef Q_OS_MAC
#include <private/qcore_mac_p.h>
CFRelease(thisString);
CFRelease(otherString);
return result;
+#elif defined(QT_USE_ICU)
+ QCollator collator;
+ return collator.compare(data1, length1, data2, length2);
#elif defined(Q_OS_UNIX)
-# if defined(QT_USE_ICU)
- QLocale locale;
- int res;
- if (QIcu::strcoll(locale.d.constData()->m_localeID, data1, length1, data2, length2, &res))
- return res;
- // else fall through
-# endif
// declared in <string.h>
int delta = strcoll(toLocal8Bit_helper(data1, length1).constData(), toLocal8Bit_helper(data2, length2).constData());
if (delta == 0)