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 <lars.knoll@digia.com>bb10
parent
6080db8c6d
commit
1abcc1cd3d
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1996,6 +1996,10 @@ void tst_QTextCodec::codecForHtml_data()
|
|||
"auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; display: inline !important; float: "
|
||||
"none;\">ͻ</span>\000";
|
||||
QTest::newRow("greek text UTF-8") << html << 106 << 106;
|
||||
|
||||
html = "<!DOCTYPE html><html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=unicode\">"
|
||||
"<head/><body><p>bla</p></body></html>"; // QTBUG-41998, ICU will return UTF-16.
|
||||
QTest::newRow("legacy unicode UTF-8") << html << 106 << 106;
|
||||
}
|
||||
|
||||
void tst_QTextCodec::codecForHtml()
|
||||
|
|
|
|||
Loading…
Reference in New Issue