[PyKDE] QByteArray and unicode

Orcan Ogetbil orcan at psu.edu
Fri Dec 23 19:11:47 GMT 2005


Hi,
using the following code, I can get the track title that's being played in 
amarok.

[code]
import dcop

dcopclient = dcop.DCOPClient()
dcopclient.registerAs("amarokapp")
dcopclient.rc = dcop.DCOPRef("amarok", "player")

result = dcopclient.rc.call("title()")
title = result.data.data()

print title
[/code]

The problem is, when the track title contains non-ascii characters, they are 
not displayed properly. 

The 'result' is a QByteArray object, 
'result.data.data()' is a ascii python string

How and where should I set the encoding to display the track title properly? 
(and how do I convert the QByteArray object to a unicode QString object?)


ps: Thx Jim, what you replied to my last email helped a lot!
-- 
Orcan Ogetbil <oogetbil at phys.psu.edu>
Physics Department
Penn State University
814-8637505
211 Osmond Lab




More information about the PyQt mailing list