[Tutor] Encoding

Stefan Behnel stefan_ml at behnel.de
Wed Mar 3 16:12:38 CET 2010


Giorgio, 03.03.2010 15:50:
>>>   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

Correct.

> s = 'Hallo World' how is encoded?

Depends on your source code encoding.

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.

The browser will tell you the encoding in the headers that it transmits.

Stefan



More information about the Tutor mailing list