summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qstring.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2012-04-23 16:39:13 +0200
committerQt by Nokia <qt-info@nokia.com>2012-05-07 05:06:26 +0200
commit592fe0a02609503670cc9238d1a4ad29e4e65185 (patch)
treea176f70a79f64e7216ffb2ef3b86018c29286e78 /src/corelib/tools/qstring.cpp
parenta637a5ae29447980459865468e74cd1356d04da5 (diff)
Change QString's default codec to be UTF-8
This is a crude change, not the most efficient way. I'll clean up and make it prettier later on, when I've had the chance to optimise the UTF-8 codec too. Change-Id: I78e30e8d3bddf6ad0210c9c4cedb9a7ce63d1a7d Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/corelib/tools/qstring.cpp')
-rw-r--r--src/corelib/tools/qstring.cpp42
1 files changed, 40 insertions, 2 deletions
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index fd0d1286f68..69650f50efa 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -369,6 +369,42 @@ inline char qToLower(char ch)
return ch;
}
+/*!
+ \internal
+*/
+bool qStringComparisonHelper(const QString &s1, const char *s2)
+{
+ // ### optimize me
+ return s1 == QString::fromAscii(s2);
+}
+
+/*!
+ \internal
+*/
+bool qStringComparisonHelper(const QString &s1, const QByteArray &s2)
+{
+ // ### optimize me
+ return s1 == QString::fromAscii(s2);
+}
+
+/*!
+ \internal
+*/
+bool qStringComparisonHelper(const QStringRef &s1, const char *s2)
+{
+ // ### optimize me
+ return s1 == QString::fromAscii(s2);
+}
+
+/*!
+ \internal
+*/
+bool qStringComparisonHelper(const QStringRef &s1, const QByteArray &s2)
+{
+ // ### optimize me
+ return s1 == QString::fromAscii(s2);
+}
+
const QString::Null QString::null = { };
/*!
@@ -3935,7 +3971,7 @@ QByteArray QString::toLatin1() const
*/
QByteArray QString::toAscii() const
{
- return toLatin1();
+ return toUtf8();
}
#if !defined(Q_OS_MAC) && defined(Q_OS_UNIX)
@@ -4064,7 +4100,9 @@ QString::Data *QString::fromLatin1_helper(const char *str, int size)
QString::Data *QString::fromAscii_helper(const char *str, int size)
{
- return fromLatin1_helper(str, size);
+ QString s = fromUtf8(str, size);
+ s.d->ref.ref();
+ return s.d;
}
/*! \fn QString QString::fromLatin1(const char *str, int size)