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

List:       kopete-devel
Subject:    Re: [Kopete-devel] Newbie, character set mystery (again)
From:       Martijn Klingens <klingens () kde ! org>
Date:       2004-01-26 20:07:00
Message-ID: 200401262107.00079.klingens () kde ! org
[Download RAW message or body]

On Sunday 25 January 2004 23:28, Robin Rosenberg wrote:
> besides I learnt a few things already. It would be nice to get some
> pointers into the interesting parts of the code, like where to
> transformation to unicode takes place and where kopee screws up and display
> the XML Document parse errror in the chatview. (eventually I'll find it
> ofcourse). My immediate goal is to patch around the error in any ugly way
> so I can go back from gaim.

For the quick hack, go to the KopeteXSLThread::xsltTransform method in 
libkopete/private/kopetexsl.cpp. There you can go over the QCString 
xmlCString in a for() loop and remove any characters that are not valid Utf8.

Alternatively you could try to re-encode in e.g. Latin1 if isUtf8 fails. In 
untested code:

- QCString xmlCString = xmlString.utf8();
+ char *rawXML = xmlString.utf8();
+ QCString xmlCString;
+ if( KStringHandler::isUtf8( rawXML ) )
+     QCString = rawXML;
+ else
+     QCString = QString::fromLatin1( rawXML ).utf8();

(And #include kstringhandler.h :)

Obviously we won't commit such a crude hack, but for your local system t might 
just do the trick.

(BTW, to answer you question on BugZilla why the Utf8 conversion in Qt can 
fail, this is a change that was deliberately made by TrollTech in Qt 3.1 that 
converts any illegal utf8 characters to a special internal encoding and 
converts them back to their original characters when calling .utf8() on the 
QString. The reason for this are mostly file names, that are often still in 
Latin1 when the rest of the system is Utf8 already. Worse, there can be mixed 
charsets on a file system. And you don't want to rename Latin1 to Utf or vice 
versa. When talking with non-Qt code like libxml however this is obviously a 
total pain. Also it makes encoding detection a lot harder.)

-- 
Martijn
_______________________________________________
Kopete-devel mailing list
Kopete-devel@kde.org
https://mail.kde.org/mailman/listinfo/kopete-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

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