[Tutor] Encoding

Giorgio anothernetfellow at gmail.com
Wed Mar 3 16:32:01 CET 2010


Uff, encoding is a very painful thing in programming.

Ok so now comes last "layer" of the encoding: the webserver.

I now know how to handle encoding in a python app and in interactions with
the db, but the last step is sending the content to the webserver.

How should i encode pages? The encoding i choose has to be the same than the
one i choose in the .htaccess file? Or maybe i can send content encoded how
i like more to apache and it re-encodes in the right way all pages?

Thankyou

2010/3/3 Patrick Sabin <patrick.just4fun at gmail.com>

> 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
>



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


More information about the Tutor mailing list