On Wed, May 9, 2012 at 7:56 PM, sesenmaister <[email protected]> wrote:
> When I use web2py 1.99.7 shell (web2py.exe -S welcome) :
>
>>>> unicode('Äpple','utf-8')
> Traceback (most recent call last):
> File "<console>", line 1, in <module>
> UnicodeDecodeError: 'utf8' codec can't decode byte 0x8e in position 0:
> unexpected code byte
Here you are saying to unicode function that the string is encoded in
utf-8 so it will try to
decode using utf-8 codec but your terminal emulator is configured to iso-8859-1
so when you enter 'Äpple' you put it encoded in iso-8859-1
>>>> unicode('Äpple','iso-8859-1')
> u'\x8epple'
> When running normally web2py (as localhost 127.0.0.1):
>
> def codificacion1():
> response.write(unicode('Äpple','utf-8'))
> response.write('<br>,escape=False')
> response.write(unicode('Äpple','iso-8859-1'))
> return ()
>
> it returns:
>
> Äpple Äpple
Here you are using some editor configured to use utf-8. So when you write
'Äpple' is in utf-8.
To see the differences from both "worlds" you can do in shell:
print repr('Äpple')
In web2py:
def codificacion1():
response.write(repr('Äpple'))
And I am almost 100% sure that you will get a different sequence of
bytes.
> How can I do for having same results in the shell?
Your terminal emulator and your editor both need to have the same
capabilities and configured identically.
Ricardo