[Tutor] Simple ROT-13 Script

Daniel Ehrenberg littledanehren at yahoo.com
Tue Feb 3 13:43:48 EST 2004


Javier JJ wrote:
> And the reason that it wont' work on other than
> ASCII.- strings ??
> 
>     I mean:
> 
>  >>> s = "asasas"
>  >>> s.encode("rot13")
> 'nfnfnf'
>  >>> type(s)
> <type 'str'>
> 
>  >>> s = "aaañññaaaaaaaa"
>  >>> s
> 'aaa\xf1\xf1\xf1aaaaaaaa'
>  >>> type(s)
> <type 'str'>
>  >>> s.encode("rot13")
> Traceback (most recent call last):
>   File "<interactive input>", line 1, in ?
>   File "C:\Python23\lib\encodings\rot_13.py", line
> 18, in encode
>     return
> codecs.charmap_encode(input,errors,encoding_map)
> UnicodeDecodeError: 'ascii' codec can't decode byte
> 0xf1 in position 3: 
> ordinal not in range(128)
>  >>>
> 
> ¿¿¿?????
> 
>     Thanks a lot...
> 
>        Javier Jarava

What would you expect that to be encoded as? There's
no a with a ~ over it. rot13 is only made to work with
ASCII. If you wanted the accent marks to just be
removed, you might want to define your own rot13
function.

Daniel Ehrenberg

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/



More information about the Tutor mailing list