[Qt-qml] UTF-8 vs. other encodings with XMLHttpRequest
ari.koivisto at nokia.com
ari.koivisto at nokia.com
Fri Aug 20 09:04:10 CEST 2010
Hi,
I've run into problems in how qml handles character encodings with XMLHttpRequest.
The web service I'm using returns either a block of text with following response header "content-type: text/plain; charset=iso-8859-1" or a text/xml response with "<?xml version="1.0" encoding="ISO-8859-1" ?>" - depending on the service request.
I'm using XmlListModel for the XML response and it seems to be working ok with iso-8859-1, but using the responseText with XMLHttpRequest ends up with non-ascii letters in black diamond question marks.
Looking at the source 4.7.0 beta 2 (qdeclarativexmlhttprequest.cpp):
---clip---
QString QDeclarativeXMLHttpRequest::responseBody() const
{
QXmlStreamReader reader(m_responseEntityBody);
reader.readNext();
QTextCodec *codec = QTextCodec::codecForName(reader.documentEncoding().toString().toUtf8());
if (codec)
return codec->toUnicode(m_responseEntityBody);
return QString::fromUtf8(m_responseEntityBody);
}
---clip---
It is trying to find the decoder with the response body and failing as the charset is set in the headers. Shouldn't the header charset be used here?
Best Regards,
Ari
More information about the Qt-qml
mailing list