Help needed with python unicode cgi-bin script

weheh weheh at verizon.net
Wed Dec 12 12:12:31 EST 2007


Hi Duncan, thanks for the reply.
>>
> FWIW, the code you posted only ever attempted to set the character set
> encoding using an html meta tag which is the wrong place to set it. The
> encoding specified in the HTTP headers always takes precedence. This is 
> why
> the default charset setting in Apache was the one which applied.
>
> What you should have been doing was setting the encoding in the content-
> type header. i.e. in this line of your code:
>
>   print u"""Content-Type: text/html
>
> You should have changed it to read:
>
>   Content-Type: text/html; charset=windows-1252
>
> but because you didn't Apache was quietly changing it to read:
>
>   Content-Type: text/html; charset=utf-8
>
Will this work under the following situation? Let's say the user is filling 
out a text field on a form on my website. The user has their browser 
encoding set to utf8. My website has charset=windows-1252 as you indicate 
above. Will I run into a conflict somewhere? 





More information about the Python-list mailing list