summaryrefslogtreecommitdiffstats
path: root/src/corelib/codecs/qtextcodec.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/codecs/qtextcodec.cpp')
-rw-r--r--src/corelib/codecs/qtextcodec.cpp26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp
index 9d13e1b892..d2857c03b6 100644
--- a/src/corelib/codecs/qtextcodec.cpp
+++ b/src/corelib/codecs/qtextcodec.cpp
@@ -253,9 +253,10 @@ static QTextCodec *setupLocaleMapper()
// textCodecsMutex need to be locked to enter this function
static void setup()
{
- QCoreGlobalData *globalData = QCoreGlobalData::instance();
- if (!globalData->allCodecs.isEmpty())
+ static bool initialized = false;
+ if (initialized)
return;
+ initialized = true;
#if !defined(QT_NO_CODECS) && !defined(QT_BOOTSTRAPPED)
(void)new QTsciiCodec;
@@ -441,7 +442,7 @@ QTextCodec::ConverterState::~ConverterState()
an empty list. For example, "ISO-8859-1" has "latin1",
"CP819", "IBM819", and "iso-ir-100" as aliases.
- \row \li mibEnum()
+ \row \li \l{QTextCodec::mibEnum()}{mibEnum()}
\li Return the MIB enum for the encoding if it is listed in
the \l{IANA character-sets encoding file}.
@@ -465,7 +466,11 @@ QTextCodec::QTextCodec()
{
QMutexLocker locker(textCodecsMutex());
- QCoreGlobalData::instance()->allCodecs.prepend(this);
+ QCoreGlobalData *globalInstance = QCoreGlobalData::instance();
+ if (globalInstance->allCodecs.isEmpty())
+ setup();
+
+ globalInstance->allCodecs.prepend(this);
}
@@ -503,7 +508,7 @@ QTextCodec *QTextCodec::codecForName(const QByteArray &name)
QCoreGlobalData *globalData = QCoreGlobalData::instance();
if (!globalData)
return 0;
- setup();
+ setup();
#ifndef QT_USE_ICU
QTextCodecCache *cache = &globalData->codecCache;
@@ -704,7 +709,7 @@ QTextCodec* QTextCodec::codecForLocale()
\fn int QTextCodec::mibEnum() const
Subclasses of QTextCodec must reimplement this function. It
- returns the MIBenum (see \l{IANA character-sets encoding file}
+ returns the \l{QTextCodec::mibEnum()}{MIBenum} (see \l{IANA character-sets encoding file}
for more information). It is important that each QTextCodec
subclass returns the correct unique value for this function.
*/
@@ -733,7 +738,7 @@ QList<QByteArray> QTextCodec::aliases() const
\a state can be 0, in which case the conversion is stateless and
default conversion rules should be used. If state is not 0, the
codec should save the state after the conversion in \a state, and
- adjust the remainingChars and invalidChars members of the struct.
+ adjust the \c remainingChars and \c invalidChars members of the struct.
*/
/*!
@@ -749,7 +754,7 @@ QList<QByteArray> QTextCodec::aliases() const
\a state can be 0 in which case the conversion is stateless and
default conversion rules should be used. If state is not 0, the
codec should save the state after the conversion in \a state, and
- adjust the remainingChars and invalidChars members of the struct.
+ adjust the \c remainingChars and \c invalidChars members of the struct.
*/
/*!
@@ -1049,7 +1054,10 @@ QTextCodec *QTextCodec::codecForHtml(const QByteArray &ba, QTextCodec *defaultCo
while (++pos2 < header.size()) {
char ch = header.at(pos2);
if (ch == '\"' || ch == '\'' || ch == '>') {
- c = QTextCodec::codecForName(header.mid(pos, pos2 - pos));
+ QByteArray name = header.mid(pos, pos2 - pos);
+ if (name == "unicode") // QTBUG-41998, ICU will return UTF-16.
+ name = QByteArrayLiteral("UTF-8");
+ c = QTextCodec::codecForName(name);
return c ? c : defaultCodec;
}
}