[Tutor] Encoding
Patrick Sabin
patrick.just4fun at gmail.com
Wed Mar 3 16:22:03 CET 2010
Giorgio wrote:
>
> Depends on your python version. If you use python 2.x, you have to
> use a u before the string:
>
> s = u'Hallo World'
>
>
> Ok. So, let's go back to my first question:
>
> s = u'Hallo World' is unicode in python 2.x -> ok
> s = 'Hallo World' how is encoded?
I am not 100% sure, but I think it depends on the encoding of your
source file or the coding you specify. See PEP 263
http://www.python.org/dev/peps/pep-0263/
> Well, the problem comes, i.e when i'm getting a string from an HTML
> form with POST. I don't and can't know the encoding, right? It depends
> on browser.
Right, but you can do something about it. Tell the browser, which
encoding you are going to accept:
<form ... accept-charset="UTF-8">
...
</form>
- Patrick
More information about the Tutor
mailing list