diff --git a/src/common/textcodec.cpp b/src/common/textcodec.cpp index 46f9709d..fd64e3aa 100644 --- a/src/common/textcodec.cpp +++ b/src/common/textcodec.cpp @@ -6,7 +6,7 @@ static QTextCodec *codec(int mib) { QTextCodec *c = QTextCodec::codecForMib(mib); if (!c) - qWarning("MIB-%d: No such QTextCodec, using UTF-8", mib); + qWarning("MIB-%d: No such QTextCodec, using ISO-8859-1", mib); return c; } @@ -61,17 +61,17 @@ TextCodec::TextCodec(int codepage) _codec = codec(2258); break; case 65001: - _codec = 0; + _codec = codec(106); break; default: - qWarning("%d: Unknown codepage, using UTF-8", codepage); + qWarning("%d: Unknown codepage, using ISO-8859-1", codepage); _codec = 0; } } QString TextCodec::toString(const QByteArray &ba) { - return _codec ? _codec->toUnicode(ba) : QString::fromUtf8(ba); + return _codec ? _codec->toUnicode(ba) : QString::fromLatin1(ba); } #else // QT 6.5 @@ -82,17 +82,19 @@ TextCodec::TextCodec() TextCodec::TextCodec(int codepage) { - if (codepage != 65001) { + if (codepage == 65001) + _decoder = QStringDecoder(QStringDecoder::Utf8); + else { QByteArray cp(QByteArray("CP") + QByteArray::number(codepage)); _decoder = QStringDecoder(cp.constData()); if (!_decoder.isValid()) - qWarning("%d: Unknown codepage, using UTF-8", codepage); + qWarning("%d: Unknown codepage, using ISO-8859-1", codepage); } } QString TextCodec::toString(const QByteArray &ba) { - return _decoder.isValid() ? _decoder.decode(ba) : QString::fromUtf8(ba); + return _decoder.isValid() ? _decoder.decode(ba) : QString::fromLatin1(ba); } #endif // QT 6.5