How to overcome automatic cyrillic-to-/hex convert
Terry Reedy
tjreedy at udel.edu
Sat Jun 11 13:59:26 EDT 2005
<degoor_python at dir.bg> wrote in message news:web-10021930 at dir.bg...
> But when I enter some Bulgarian (actually cyrillic) text as a string,
> it
> seems that Python automatically converts it to '\x00..\x00 ' and once
> converted that way I can't get it back into its original look. The only
> way to get it right is using print :
>
>>>> a = 'ÌÀÌÀ' # 'Mam' in Bulgarian
>>>> print a
> 'ÌÀÌÀ'
>
> but
>
>>>> a
> '\xcc\xe0\xec\xe0'
There is a difference between internal data and external presentation.
Print a calls str(a) to get a 'nice' presentation. Echoing 'a' calls
repr(a) to get an invertible presentation (eval(repr(somestring)) ==
somestring). Internally, 'a' is the 4 bytes indicated by the repr
presentation, not the 16 chars displayed in that presentation. There is no
conversion until that presentation.
I cannot comment about wxGrid and how to get it to display the nice version
you want.
Terry J. Reedy
More information about the Python-list
mailing list