summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2012-07-25 10:17:44 +0200
committerQt by Nokia <qt-info@nokia.com>2012-07-31 11:12:44 +0200
commitb23f048cf9a8eca4a246c65298818c38a4338fe4 (patch)
tree9bd8c34dca71efc2aa9ded533fb8b7764ec1963f /src
parent34721c4d3690335d2d9fe79620e566fda78de25b (diff)
Use ICU instead of iconv/windows codecs for the locale
With ICU there's no need to use the windows locale or iconv codecs anymore as locale codecs. Change-Id: I50c94a97ed6acbf4c6f05b2a88593a57ebfa8342 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/codecs/codecs.pri42
-rw-r--r--src/corelib/codecs/qicucodec.cpp16
-rw-r--r--src/corelib/codecs/qicucodec_p.h2
-rw-r--r--src/corelib/codecs/qtextcodec.cpp25
4 files changed, 50 insertions, 35 deletions
diff --git a/src/corelib/codecs/codecs.pri b/src/corelib/codecs/codecs.pri
index d049e52275..0b40f795ad 100644
--- a/src/corelib/codecs/codecs.pri
+++ b/src/corelib/codecs/codecs.pri
@@ -39,26 +39,26 @@ contains(QT_CONFIG,icu) {
codecs/qsjiscodec.cpp \
codecs/qeuckrcodec.cpp \
codecs/qbig5codec.cpp
-}
-unix:!qnx:!mac:!ios:!linux-android-* {
- contains(QT_CONFIG,iconv) {
- HEADERS += codecs/qiconvcodec_p.h
- SOURCES += codecs/qiconvcodec.cpp
- } else:contains(QT_CONFIG,gnu-libiconv) {
- HEADERS += codecs/qiconvcodec_p.h
- SOURCES += codecs/qiconvcodec.cpp
- DEFINES += GNU_LIBICONV
- LIBS_PRIVATE *= -liconv
- } else:contains(QT_CONFIG,sun-libiconv) {
- HEADERS += codecs/qiconvcodec_p.h
- SOURCES += codecs/qiconvcodec.cpp
- DEFINES += GNU_LIBICONV
- }
-} else {
- DEFINES += QT_NO_ICONV
-}
-win32 {
- SOURCES += codecs/qwindowscodec.cpp
- HEADERS += codecs/qwindowscodec_p.h
+ unix:!qnx:!mac:!ios:!linux-android-* {
+ contains(QT_CONFIG,iconv) {
+ HEADERS += codecs/qiconvcodec_p.h
+ SOURCES += codecs/qiconvcodec.cpp
+ } else:contains(QT_CONFIG,gnu-libiconv) {
+ HEADERS += codecs/qiconvcodec_p.h
+ SOURCES += codecs/qiconvcodec.cpp
+ DEFINES += GNU_LIBICONV
+ LIBS_PRIVATE *= -liconv
+ } else:contains(QT_CONFIG,sun-libiconv) {
+ HEADERS += codecs/qiconvcodec_p.h
+ SOURCES += codecs/qiconvcodec.cpp
+ DEFINES += GNU_LIBICONV
+ }
+ } else {
+ DEFINES += QT_NO_ICONV
+ }
+ win32 {
+ SOURCES += codecs/qwindowscodec.cpp
+ HEADERS += codecs/qwindowscodec_p.h
+ }
}
diff --git a/src/corelib/codecs/qicucodec.cpp b/src/corelib/codecs/qicucodec.cpp
index c91115b3b5..56efcad14e 100644
--- a/src/corelib/codecs/qicucodec.cpp
+++ b/src/corelib/codecs/qicucodec.cpp
@@ -372,7 +372,6 @@ QList<QByteArray> QIcuCodec::availableCodecs()
// handled by Qt and not in ICU:
codecs += "TSCII";
- codecs += "System";
return codecs;
}
@@ -389,6 +388,21 @@ QList<int> QIcuCodec::availableMibs()
return mibs;
}
+QTextCodec *QIcuCodec::defaultCodec()
+{
+ QCoreGlobalData *globalData = QCoreGlobalData::instance();
+ if (!globalData)
+ return 0;
+ QTextCodec *c = globalData->codecForLocale.loadAcquire();
+ if (c)
+ return c;
+
+ const char *name = ucnv_getDefaultName();
+ c = codecForName(name);
+ globalData->codecForLocale.storeRelease(c);
+ return c;
+}
+
static inline bool nameMatch(const QByteArray &a, const char *b)
{ return a == b; }
diff --git a/src/corelib/codecs/qicucodec_p.h b/src/corelib/codecs/qicucodec_p.h
index 5f30eac3cc..0a8ac7d996 100644
--- a/src/corelib/codecs/qicucodec_p.h
+++ b/src/corelib/codecs/qicucodec_p.h
@@ -67,6 +67,8 @@ public:
static QList<QByteArray> availableCodecs();
static QList<int> availableMibs();
+ static QTextCodec *defaultCodec();
+
static QTextCodec *codecForName(const char *name);
static QTextCodec *codecForMib(int mib);
diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp
index 3b0afdd6cc..6fef7794e6 100644
--- a/src/corelib/codecs/qtextcodec.cpp
+++ b/src/corelib/codecs/qtextcodec.cpp
@@ -54,15 +54,6 @@
#endif
#include "private/qcoreglobaldata_p.h"
-#if !defined(QT_BOOTSTRAPPED)
-#if !defined(QT_NO_ICONV)
-# include "qiconvcodec_p.h"
-#endif
-#ifdef Q_OS_WIN
-# include "qwindowscodec_p.h"
-#endif
-#endif
-
#include "qutfcodec_p.h"
#include "qlatincodec_p.h"
@@ -72,6 +63,12 @@
#if defined(QT_USE_ICU)
#include "qicucodec_p.h"
#else
+#if !defined(QT_NO_ICONV)
+# include "qiconvcodec_p.h"
+#endif
+#ifdef Q_OS_WIN
+# include "qwindowscodec_p.h"
+#endif
# include "qsimplecodec_p.h"
#if !defined(QT_NO_BIG_CODECS)
# ifndef Q_OS_INTEGRITY
@@ -173,10 +170,12 @@ static QTextCodec *setupLocaleMapper()
QCoreApplicationPrivate::initLocale();
#endif
-#if defined(Q_OS_WIN) || defined(Q_OS_WINCE)
- locale = QTextCodec::codecForName("System");
-#elif defined(Q_OS_MAC) || defined(Q_OS_IOS) || defined(Q_OS_LINUX_ANDROID) || defined(Q_OS_QNX)
+#if defined(Q_OS_MAC) || defined(Q_OS_IOS) || defined(Q_OS_LINUX_ANDROID) || defined(Q_OS_QNX)
locale = QTextCodec::codecForName("UTF-8");
+#elif defined(QT_USE_ICU)
+ locale = QIcuCodec::defaultCodec();
+#elif defined(Q_OS_WIN) || defined(Q_OS_WINCE)
+ locale = QTextCodec::codecForName("System");
#else
// First try getting the codecs name from nl_langinfo and see
@@ -287,13 +286,13 @@ static void setup()
(void)new QBig5Codec;
(void)new QBig5hkscsCodec;
# endif // !QT_NO_BIG_CODECS && !Q_OS_INTEGRITY
-#endif // QT_USE_ICU
#if !defined(QT_NO_ICONV)
(void) new QIconvCodec;
#endif
#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
(void) new QWindowsLocalCodec;
#endif // Q_OS_WIN32
+#endif // QT_USE_ICU
#endif // !QT_NO_CODECS && !QT_BOOTSTRAPPED
(void)new QUtf16Codec;