[Tutor] same output on diferent sys.stdout.encodings

Paulino paulino1 at sapo.pt
Wed Feb 7 18:30:26 CET 2007

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 "d\xe9bito" 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?

More information about the Tutor mailing list