[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: Re: [PyKDE] Converting font names to python strings
From: "Giovanni Bajo" <rasky () develer ! com>
Date: 2005-04-19 13:49:49
Message-ID: 0ab301c544e6$a773d400$bf03030a () trilan
[Download RAW message or body]
Jeremy Sanders <jeremy@jeremysanders.net> wrote:
> One of my users is having problems with my code. It looks like it might be
> to do with converting QStrings to Python strings if they are unicode:
>
> The code is:
>
> db = qt.QFontDatabase()
>
> # build a dict up with the list of families
> families = {}
> for i in db.families():
> families[str(i)] = True
>
> This gives an exception:
> UnicodeEncodeError: 'ascii' codec can't encode characters in position
> 0-6: ordinal not in range(128)
>
> I had assumed this would just work. Am I wrong? Any ideas???
You could use unicode(i) to convert QString to a Python unicode string.
Either that, or keep the QString. It pretty much depends on what you are
going to do with that families dict.
--
Giovanni Bajo
_______________________________________________
PyKDE mailing list PyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic