Summary: | Pipes plugin doesn't support Unicode | ||
---|---|---|---|
Product: | [Unmaintained] kopete | Reporter: | Christoph Burgmer <chrislb> |
Component: | Pipes Plugin | Assignee: | Kopete Developers <kopete-bugs-null> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | NOR | ||
Version First Reported In: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Debian testing | ||
OS: | Unspecified | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: | |||
Attachments: | Proposed fix for "pipes" plugin encoding issues |
Description
Christoph Burgmer
2008-10-20 17:09:47 UTC
See http://websvn.kde.org/trunk/playground/network/kopete/plugins/pipes/pipesplugin.cpp?revision=746167&view=markup // poop out appropriate data if ( pipeOptions.pipeContents == HtmlBody ) pipe.write ( msg.escapedBody().toLocal8Bit() ); else if ( pipeOptions.pipeContents == PlainBody ) pipe.write ( msg.plainBody().toLocal8Bit() ); else if ( pipeOptions.pipeContents == Xml ) pipe.write ( createXml ( msg ).toLocal8Bit() ); Everything is piped through using 8 bit without any encoding conversion. Can somebody confirm that this bug is or is not simply solved by replacing toLocal8Bit() with toUtf8()? Both return a QByteArray, but for me only toUtf8() actually does not delete non-ASCII characters: $ python Python 2.5.2 (r252:60911, Nov 14 2008, 19:46:32) [GCC 4.3.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from PyQt4.QtCore import QString >>> a = QString(u"你好") >>> a PyQt4.QtCore.QString(u'\u4f60\u597d') >>> a.toUtf8() PyQt4.QtCore.QByteArray('\xe4\xbd\xa0\xe5\xa5\xbd') >>> a.toLocal8Bit() PyQt4.QtCore.QByteArray('') >>> I don't really understand Qt's behaviour/documentation here. On [1] is states, that the system's encoding is used for conversion to 8 bit. My system uses utf8, and in the case of using 2-/4-byte encodings, I can't guess the semantics of that method. [1] http://doc.trolltech.com/4.4/qstring.html#toLocal8Bit Created attachment 29362 [details]
Proposed fix for "pipes" plugin encoding issues
I've attached a patch that seems to fix the problem for me. I've tested plain text and xml input/output. The main problem, as far as I can tell, was that data coming back from the QProcess was implicitly converted to ascii when the QByteArray output was assigned to a QString. The patch contains some other modifications as well to reduce the number of conversions back and forth. The patch applies inside the "pipes" directory.
This patch seems not to address my specific problem with plain text. Please take that into account when applying the patch. SVN commit 912005 by rjarosz: Fix bug 173195: Pipes plugin doesn't support Unicode. Patch by Sebastian Strand, thanks. BUG: 173195 M +12 -12 pipesplugin.cpp M +3 -3 pipesplugin.h WebSVN link: http://websvn.kde.org/?view=rev&revision=912005 SVN commit 912008 by rjarosz: Backport fix for bug 173195: Pipes plugin doesn't support Unicode. Patch by Sebastian Strand, thanks. CCBUG: 173195 M +12 -12 pipesplugin.cpp M +3 -3 pipesplugin.h WebSVN link: http://websvn.kde.org/?view=rev&revision=912008 |