Version: (using KDE KDE 3.4.1) Installed from: Gentoo Packages Compiler: gcc 3 OS: Linux When I am trying to load an html fragment via XMLHttpRequest() and display it via *.innerHTML = *.responseText it shows up, I believe, in Latin encoding. Which is not the case for Firefox, MSIE and Opera. You can check out the behaviour at http://hacker.klever.net/range/konqueror-charset-bug/ which loads http://hacker.klever.net/range/konqueror-charset-bug/to-load.html Both documents return Content-Type: text/html; charset=windows-1251
I can reproduce (trunk 424191).
The attached patch should fix the problem. On Friday 01 July 2005 20:48, Thiago Macieira wrote: [bugs.kde.org quoted mail] Created an attachment (id=11811) xmlhttprequest.diff
I can confirm it fixes the problem. If you'll be so kind, Dawit, commit it :-)
Great, I've seen you working in the logs ;-) Hope it's okay if I eventually remove the files I've put on the web.
SVN commit 434817 by adawit: - Use the charset provided by the remote host through the HTTP headers. BUG: 108400@bugs.kde.org M +12 -0 xmlhttprequest.cpp --- trunk/KDE/kdelibs/khtml/ecma/xmlhttprequest.cpp #434816:434817 @@ -553,6 +553,18 @@ #endif if ( decoder == NULL ) { + int pos = responseHeaders.find("Content-Type:"); + if ( pos > -1 ) + { + int index = responseHeaders.find('\n', pos+13); + QString type = responseHeaders.mid(pos+13, index); + // qDebug("XMLHttpRequest::slotData: 'content-type = %s'", type.latin1()); + index = type.find (';'); + if (index > -1) + encoding = type.mid( index+1 ).remove(QRegExp("charset[ ]*=[ ]*", false)).stripWhiteSpace(); + // qDebug("XMLHttpRequest::slotData: 'encoding = %s'", encoding.latin1()); + } + decoder = new Decoder; if (!encoding.isNull()) decoder->setEncoding(encoding.latin1(), Decoder::EncodingFromHTTPHeader);
guys, your patch doesn't work for me. Please double check. Cheers, Anton ps. I think you have to apply it "encoding" after if (!encoding.isNull()) decoder->setEncoding(encoding.latin1(), Decoder::EncodingFromHTTPHeader); In the "fixme" line.