[Qt-qml] UTF-8 vs. other encodings with XMLHttpRequest
bea.lam at nokia.com
bea.lam at nokia.com
Tue Aug 24 06:45:46 CEST 2010
On 20/08/2010, at 5:04 PM, ext ari.koivisto at nokia.com wrote:
> 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?
>
Thanks, reported as http://bugreports.qt.nokia.com/browse/QTBUG-13117.
More information about the Qt-qml
mailing list