diff options
author | Olivier Goffart <olivier.goffart@nokia.com> | 2011-04-20 10:52:58 (GMT) |
---|---|---|
committer | Olivier Goffart <olivier.goffart@nokia.com> | 2011-04-20 10:52:58 (GMT) |
commit | 40a2129c60f21ea6f146d405ebcadb25628db273 (patch) | |
tree | 1a61e8ab7cc90c698c4def62439a2acc0cec6bad /src/corelib/tools/qstring.cpp | |
parent | 8485052e3991aebf7c823b3e80fc06ccf9f08991 (diff) | |
parent | 7a9ed6a1983e318bfb14f0b2db41b3a4e1415529 (diff) | |
download | Qt-40a2129c60f21ea6f146d405ebcadb25628db273.zip Qt-40a2129c60f21ea6f146d405ebcadb25628db273.tar.gz Qt-40a2129c60f21ea6f146d405ebcadb25628db273.tar.bz2 |
Merge remote-tracking branch 'earth-team/master' into earth-staging-master
Diffstat (limited to 'src/corelib/tools/qstring.cpp')
-rw-r--r-- | src/corelib/tools/qstring.cpp | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index b7272ec..5493ba9 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -106,6 +106,14 @@ QTextCodec *QString::codecForCStrings; static QHash<void *, QByteArray> *asciiCache = 0; #endif +#ifdef QT_USE_ICU +// qlocale_icu.cpp +extern bool qt_ucol_strcoll(const QChar *source, int sourceLength, const QChar *target, int targetLength, int *result); +extern bool qt_u_strToUpper(const QString &str, QString *out, const QLocale &locale); +extern bool qt_u_strToLower(const QString &str, QString *out, const QLocale &locale); +#endif + + // internal int qFindString(const QChar *haystack, int haystackLen, int from, const QChar *needle, int needleLen, Qt::CaseSensitivity cs); @@ -431,7 +439,6 @@ const QString::Null QString::null = { }; \ingroup shared \ingroup string-processing - QString stores a string of 16-bit \l{QChar}s, where each QChar corresponds one Unicode 4.0 character. (Unicode characters with code values above 65535 are stored using surrogate pairs, @@ -4829,6 +4836,14 @@ int QString::localeAwareCompare_helper(const QChar *data1, int length1, TPtrC p2 = TPtrC16(reinterpret_cast<const TUint16 *>(data2), length2); return p1.CompareC(p2); #elif defined(Q_OS_UNIX) +# if defined(QT_USE_ICU) + int res; + if (qt_ucol_strcoll(data1, length1, data2, length2, &res)) { + if (res == 0) + res = ucstrcmp(data1, length1, data2, length2); + return res; + } // else fall through +# endif // declared in <string.h> int delta = strcoll(toLocal8Bit_helper(data1, length1), toLocal8Bit_helper(data2, length2)); if (delta == 0) @@ -4964,6 +4979,15 @@ QString QString::toLower() const if (!d->size) return *this; +#ifdef QT_USE_ICU + { + QString result; + if (qt_u_strToLower(*this, &result, QLocale())) + return result; + // else fall through and use Qt's toUpper + } +#endif + const ushort *e = d->data + d->size; // this avoids one out of bounds check in the loop @@ -5055,6 +5079,15 @@ QString QString::toUpper() const if (!d->size) return *this; +#ifdef QT_USE_ICU + { + QString result; + if (qt_u_strToUpper(*this, &result, QLocale())) + return result; + // else fall through and use Qt's toUpper + } +#endif + const ushort *e = d->data + d->size; // this avoids one out of bounds check in the loop |