On Wed, 07 Feb 2007 17:30:26 +0000
Paulino <paulino1 sapo.pt> wrote:
> Hi everyone!
>
> I have some strings that include special characters, to
be displayed in
> widget labels ( PyQt4 ).
> The output changes in diferent OS's due to diferent
sys.stdout encoding
>
> Not only the labels in the GUI change, but the source
file strings are
> altered when I move from win to linux and vice-versa.
>
> The solution I found for now was to replace the special
characters in
> the source file string for their representation:
> I replaced "é" (e acute ) by "xe9"
wich correpsond to chr(233) in the
> cp1252 encoding.
>
> The character é (e acute) in linux is not recognized in
the source file,
> neither in IDLE nor in Kate
> My win sys.stdout.encoding is cp850 and the linux one
is utf-8
>
> Now I have "dxe9bito" instead of
"débito" (debit in portuguese). By
> passing the string through unicode with the convinient
encoding, I
> ensure the labels are exibithed the same in every OS
but, this way the
> code is not very readable.
>
> Is there a way of solving this, keeping the more
readable?
> _______________________________________________
Have you tried to declare the encoding in use at the top of
your Python source file, like:
# -*- coding: iso-8859-1 -*-
If you put this at the first line of your .py files (of
course replace iso-8859-1 with whatever
encoding you use) I think this should do the trick.
I hope this helps
Michael
_______________________________________________
Tutor maillist - Tutor python.org
http://
mail.python.org/mailman/listinfo/tutor
|