summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qlocale.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2011-08-19 12:17:06 +0200
committerQt by Nokia <qt-info@nokia.com>2011-08-31 13:12:43 +0200
commit3526560d60ef82cd04e4fdf2e0ab751c0aca9731 (patch)
treea8b6ca6427ef7f331a5508a90dfc335c050d0044 /src/corelib/tools/qlocale.cpp
parent46ff3a4b1f0ee9fc87bafe2679f322aab689889c (diff)
Add QLocale::toUpper/Lower
The toUpper/Lower() methods in QString should not be locale dependent, as this can lead to rather hard to find bugs in at least a turkish locale. Rather have explicit, locale dependend case conversions available in QLocale. Reviewed-by: Denis Dzyubenko (cherry picked from commit da0e1e101bb4c44c25b6523357fa81ad1b2d6539) Change-Id: I1cc3f341bef17ad573a736dc94c9c5d514ace54e Reviewed-on: http://codereview.qt.nokia.com/3259 Reviewed-by: Lars Knoll <lars.knoll@nokia.com> Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Diffstat (limited to 'src/corelib/tools/qlocale.cpp')
-rw-r--r--src/corelib/tools/qlocale.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
index 4648ca155d..36c4ae75a5 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -88,6 +88,8 @@ Q_GLOBAL_STATIC(QLocalePrivate, globalLocalePrivate)
#ifdef QT_USE_ICU
extern bool qt_initIcu(const QString &localeName);
+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
/******************************************************************************
@@ -2170,6 +2172,42 @@ Qt::LayoutDirection QLocale::textDirection() const
return Qt::LeftToRight;
}
+/*!
+ \since 4.8
+
+ Returns an uppercase copy of \a str.
+*/
+QString QLocale::toUpper(const QString &str) const
+{
+#ifdef QT_USE_ICU
+ {
+ QString result;
+ if (qt_u_strToUpper(str, &result, *this))
+ return result;
+ // else fall through and use Qt's toUpper
+ }
+#endif
+ return str.toUpper();
+}
+
+/*!
+ \since 4.8
+
+ Returns a lowercase copy of \a str.
+*/
+QString QLocale::toLower(const QString &str) const
+{
+#ifdef QT_USE_ICU
+ {
+ QString result;
+ if (qt_u_strToLower(str, &result, *this))
+ return result;
+ // else fall through and use Qt's toUpper
+ }
+#endif
+ return str.toLower();
+}
+
/*!
\since 4.5