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>
This commit is contained in:
Lars Knoll 2012-07-25 10:17:44 +02:00 committed by Qt by Nokia
parent 34721c4d36
commit b23f048cf9
4 changed files with 50 additions and 35 deletions

View File

@ -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
}
}

View File

@ -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; }

View File

@ -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);

View File

@ -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;