char 128? no... 256

Erik Max Francis max at alcyone.com
Tue Feb 11 22:40:08 EST 2003


Afanasiy wrote:

> UnicodeError: ASCII encoding error: ordinal not in range(128)
> 
> This isn't even unicode, it's extended ascii characters used in
> foreign
> languages.

That's not ASCII; ASCII is 7-bit clean.  If you're getting a Unicode
error, then it _is_ a Unicode object you're dealing with, whether you
like it or not.

> I can't print them, or write them to file, etc... They are
> normal chars. This really annoying, a str() around it doesn't even
> work.

There's a FAQ entry on this.

	http://www.python.org/doc/FAQ.html#4.102

You're trying to convert a Unicode string to a stream of bytes, and what
that stream of bytes will look like strongly depends on what form of
encoding you want.

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ Do not seek death.  Death will find you.
\__/ Dag Hammarskjold
    Esperanto reference / http://www.alcyone.com/max/lang/esperanto/
 An Esperanto reference for English speakers.




More information about the Python-list mailing list