From cc1435952d796476616f54319c1ddf57eeaf80f7 Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Fri, 17 Oct 2014 15:56:05 +0200 Subject: Doc: link to MIBenum Task-number: QTBUG- 40362 Change-Id: I0261117d8aef8383ef77887a201d61ed0bd0ba52 Reviewed-by: Mitch Curtis --- src/corelib/codecs/qtextcodec.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/corelib/codecs/qtextcodec.cpp') diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp index 9d13e1b8929..24cb4e70386 100644 --- a/src/corelib/codecs/qtextcodec.cpp +++ b/src/corelib/codecs/qtextcodec.cpp @@ -441,7 +441,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}. @@ -704,7 +704,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 +733,7 @@ QList 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 +749,7 @@ QList 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. */ /*! -- cgit v1.2.3 From 1abcc1cd3d1a8d04ccfd711c3293d0c671af3c78 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 27 Oct 2014 10:45:47 +0100 Subject: Hardcode UTF-8 for "unicode" in QTextCodec::codecForHtml(). ICU would return a utf-16 (endian dependent) codec for unicode which is very rarely what people want. In most cases, unicode is encoded in utf8 these days, so return a utf8 codec for it. Task-number: QTBUG-41998 Change-Id: I51ee758d520702b263a8b2011787eb1f3455ed96 Reviewed-by: Lars Knoll --- src/corelib/codecs/qtextcodec.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/corelib/codecs/qtextcodec.cpp') diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp index 24cb4e70386..9af307ca17d 100644 --- a/src/corelib/codecs/qtextcodec.cpp +++ b/src/corelib/codecs/qtextcodec.cpp @@ -1049,7 +1049,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; } } -- cgit v1.2.3 From c99b93e55c642cd8bf33cfe54efede623d5ca553 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Mon, 20 Oct 2014 15:53:54 +0200 Subject: QTextCodec: Fix source code indentation Change-Id: Ia9a79e659e028eb6173a7adef12d4973f78c32e9 Reviewed-by: Liang Qi --- src/corelib/codecs/qtextcodec.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib/codecs/qtextcodec.cpp') diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp index 9af307ca17d..bceead72f3e 100644 --- a/src/corelib/codecs/qtextcodec.cpp +++ b/src/corelib/codecs/qtextcodec.cpp @@ -503,7 +503,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; -- cgit v1.2.3 From 51ec20d93e97c777fc89e96d8d035d999c8a4ad9 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Mon, 20 Oct 2014 16:16:54 +0200 Subject: Load default codecs even if custom QTextCodec has been registered Task-number: QTBUG-40378 Change-Id: I33f1e92127972e1346993aa4e07731bf4b697667 Reviewed-by: Lars Knoll --- src/corelib/codecs/qtextcodec.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/corelib/codecs/qtextcodec.cpp') diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp index bceead72f3e..d2857c03b6a 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; @@ -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); } -- cgit v1.2.3