Showing native 8-bit strings in Python interpreter

B

braver

I'm storing 8-bit characters from the 128-256 range in Python
strings. They are Windows CP1251 Russian characters. When looking at
those strings in the Python interpreter, they come up as codes inside
the string. How can I teach Python to show those 8-bit characters in
the native encoding of the terminal -- in the current locale -- where
the interpreter was started?

Cheers,
Alexy
 
D

Diez B. Roggisch

braver said:
I'm storing 8-bit characters from the 128-256 range in Python
strings. They are Windows CP1251 Russian characters. When looking at
those strings in the Python interpreter, they come up as codes inside
the string. How can I teach Python to show those 8-bit characters in
the native encoding of the terminal -- in the current locale -- where
the interpreter was started?

The python-interpreter will print them out using hex because it calls
repr(string) - to prevent any encoding-related troubles.

But printing them will meet your expectations. See below:

Python 2.5.1 (r251:54863, May 2 2007, 16:56:35)

Diez
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top