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

List:       pykde
Subject:    Re: [PyKDE] QString to Python string conversion trouble
From:       Andreas Gerstlauer <gerstl () ics ! uci ! edu>
Date:       2001-10-25 23:46:31
[Download RAW message or body]

Boudewijn Rempt <boud@valdyas.org> said:
>
> I'm just now revising that chapter - and I would really like to have
> both str(QString("\u4011\u4012")) and unicode(QString("\u4011\u4012"))
> return the same Python Unicode object, that contains the right characters,
> prefarably not an unicode-escape-encoded plain Python string.
> 
But str() will always return a string object, not a unicode object (str() 
returns a string, unicode() a unicode Python object), no?. That's
how str() (vs. unicode()) is defined in Python, isn't it? Changing that
would require changing the Python interpreter itself...
(and also, for example, if you do 'str(u"...")' in normal Python you will
get a string object, not a unicode object)

What will hopefully be the future implementation is that unicode() returns
a Python unicode with the right characters (no encoding) and str() returns
a Python string using the default encoding for any unicode characters (> 128)
(with the possibility of an exception if there are chars > 128 and default
encoding is left at ASCII). That would be desired IMHO. 

Andreas







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

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