[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: [PATCH]: KNewsTicker querying non-ISO8859-1 sites
From:       Lars Knoll <lars () trolltech ! com>
Date:       2002-03-08 12:45:02
[Download RAW message or body]

> Hi,
>
> the attached patch, courtesy of Volker Augustin
> <volker.augustin@perfektionismus.de> apparently makes cyrillic characters
> as well as german umlauts work in KNewsTicker. I hope it makes asian
> charsets work as well, but I didn't yet find a suitable font.
>
> You can use the URLs http://www.slashdot.jp/slashdot.rdf (japanese),
> http://www.hamovniki.net/~d00mer/lenta_rdf/lenta.rdf (russian) and
> http://www.heise.de/newsticker/heise.rdf (german) to test. Just in case
> somebody has one of those giant unicode fonts handy.
>
> Ok to commit?

The patch is way to complicated and disregards that QXml can do the decoding 
work for you. QXml can autodetect the encoding, if you don't use the 
QDomDocument::setContent( Q(C)String ) method, but setContent( QByteArray ).

Please try the one liner attached. Seems to work fine for me for the russian 
page.

Lars

["xmlaccess.diff" (text/x-diff)]

Index: xmlnewsaccess.cpp
===================================================================
RCS file: /home/kde/kdenetwork/knewsticker/common/xmlnewsaccess.cpp,v
retrieving revision 1.27
diff -u -r1.27 xmlnewsaccess.cpp
--- xmlnewsaccess.cpp	2002/02/09 22:33:37	1.27
+++ xmlnewsaccess.cpp	2002/03/08 12:46:36
@@ -72,7 +72,7 @@
 	if (okSoFar) {
 		QDomDocument domDoc;
 		// Some servers like to prepend a blank line, QDom doesn't like that...
-		if (validContent = domDoc.setContent(QCString(data).stripWhiteSpace())) {
+		if (validContent = domDoc.setContent(QByteArray(QCString(data).stripWhiteSpace()))) {
 			QDomNode channelNode = domDoc.documentElement().namedItem(QString::fromLatin1("channel"));
 	
 			m_name = channelNode.namedItem(QString::fromLatin1("title")).toElement().text().simplifyWhiteSpace();


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic