fix regression since 0199f108f1 and cc7809a775

default fallback of QTextCodec::codecForUtfText() is Latin1 thus fallback
has to be specified explicitly

Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
Ivailo Monev 2020-02-03 21:59:41 +00:00
parent e40a59ee1f
commit 88448f30b6
2 changed files with 6 additions and 11 deletions

View file

@ -1385,11 +1385,9 @@ ushort QXmlStreamReaderPrivate::getChar_helper()
return 0;
}
codec = QTextCodec::codecForUtfText(rawReadBuffer);
if (!codec) {
// fallback to UTF-8 even for non-UTF data
codec = QTextCodec::codecForName("UTF-8");
}
// fallback to UTF-8 even for non-UTF data
QTextCodec *fallback = QTextCodec::codecForName("UTF-8");
codec = QTextCodec::codecForUtfText(rawReadBuffer, fallback);
Q_ASSERT(codec);
decoder = codec->makeDecoder();
}

View file

@ -1548,7 +1548,7 @@ QString QXmlInputSource::fromRawData(const QByteArray &data, bool beginning)
d->encMapper = Q_NULLPTR;
}
int mib = 106; // UTF-8
int mib = 106; // fallback to UTF-8 even for non-UTF data
// This is the initial UTF codec we will read the encoding declaration with
if (!d->encMapper) {
@ -1556,11 +1556,8 @@ QString QXmlInputSource::fromRawData(const QByteArray &data, bool beginning)
d->encodingDeclChars.clear();
d->lookingForEncodingDecl = true;
QTextCodec *codec = QTextCodec::codecForUtfText(data);
if (!codec) {
// fallback to UTF-8 even for non-UTF data
codec = QTextCodec::codecForName("UTF-8");
}
QTextCodec *fallback = QTextCodec::codecForMib(mib);
QTextCodec *codec = QTextCodec::codecForUtfText(data, fallback);
Q_ASSERT(codec);
mib = codec->mibEnum();