[Tutor] encodings

Magnus Lyckå magnus@thinkware.se
Mon Jun 16 16:22:20 2003


At 16:19 2003-06-16 +0400, Denis Dzyubenko wrote:
>On Sat, 14 Jun 2003 23:30:20 +0200,
>  Magnus Lyck(ML) wrote to me:
>
>ML> Clearer now?
>
>Yes, now it is clear.

But not solved... :(

>no, 'print s' prodices error:
>'UnicodeError: ASCII encoding error: ordinal not in range(128)'

Are you doing this in IDLE? IDLE has problems with non-ASCII
strings. Try using the plain interpreter, or run scripts.

> >>> txt = "ÁÂ×"
> >>> type(txt)
><type 'string'>
> >>> txt.decode("koi8-r")
>Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>AttributeError: decode
>
>and dir(txt) doesn't contain attribute 'decode'

Are you by any chance using an old version of Python?
Decode is new in 2.2. But I guess you can do this instead.

unicode(txt, 'koi8-r')


--
Magnus Lycka (It's really Lyck&aring;), magnus@thinkware.se
Thinkware AB, Sweden, www.thinkware.se
I code Python ~ The Agile Programming Language