Joined: 28 May 2005
Location: Looking over your shoulder.
|Posted: Fri Mar 07, 2008 4:35 pm Post subject: PyDCOP and Unicode
|I'm working on a music-related DCOP application for interfacing with Amarok in Python, but the lack of Unicode support prevents me from doing too much with my collection. For example, I can pass an artist who has a romanized name to amarok.collection.query() and it'll return the songs using Python's Unicode encoding method ('\xNN'), but if I pass an artist with a Japanese name to the same function, it returns nothing.
Here's the code for the function:
Passing '中島みゆき' to the function gives this output:
| def fquery(self, amarok = False, title = None, artist = None, album = None):
amarok = self.amarok
base = "SELECT tags.url FROM tags INNER JOIN artist ON artist.id = tags.artist LEFT OUTER JOIN album ON album.id = tags.album LEFT OUTER JOIN year ON year.id = tags.year"
supp = self.QList()
supp += ["tags.title = '%s'" % (escape(title),)]
supp += ["artist.name = '%s'" % (escape(artist),)]
supp += ["album.name = '%s'" % (escape(album),)]
base += ' WHERE ' + str(supp)
ret = amarok.collection.query(base)
Is there anything I can do with this?
|artist.name = '中島みゆき' artist.name = '中島みゆき'
SELECT tags.url FROM tags INNER JOIN artist ON artist.id = tags.artist LEFT OUTER JOIN album ON album.id = tags.album LEFT OUTER JOIN year ON year.id = tags.year WHERE artist.name = '中島みゆき'
I've managed to get some other things working with Unicode by piping the data to the 'dcop' command-line client, but the output from piping out of it won't be structured, and would require a lot of extra work to parse. For all I know, Python's pipe setup may somehow corrupt the Unicode being output by the DCOP client.
[ Kawa-kun, new and improved!! ]
Alex Libman seems to be more of an anarchist than a libertarian.