[Tutor] Encoding

Giorgio anothernetfellow at gmail.com
Wed Mar 3 15:50:25 CET 2010


>
>
>>  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 think the encoding of the db doesn't matter much in this case, but I
> would prefer utf-8 over latin-1. If you get an utf-8 encoded raw byte string
> you call .decode('utf-8'). In case of an latin-1 encoded string you call
> .decode('latin1')
>

Ok, setting it to UTF-8.


> If you don't know the encoding on the way in, reject the input.
>
>
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.

Giorgio



-- 
--
AnotherNetFellow
Email: anothernetfellow at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100303/9681bad9/attachment.html>


More information about the Tutor mailing list