[mod_python] How to set utf-8 charset from mod_python?

export at hope.cz export at hope.cz
Thu Feb 1 04:25:44 EST 2007



> Like req.write(' <html>....').encode('utf-8')
> 
> Or
> 
> Def do_some_processing(Req):
>  Req.return_html+="<!-- -->\n"
> 
> Handler(Req):
>  Req.return_html=""
>  Req.return_html+="<html>....\n"
>       do_some_processing(Req)
>  Req.write(Req.return_html).encode('utf-8')
>  ......
> 
> 
> Martijn

Martin,
Thank you for your reply.
>req.write(' <html>....').encode('utf-8') 
That  does not work for me. I receive the error:
AttributeError: 'NoneType' object has no attribute 'encode' 

I normally use
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
in my HTRL page but it does NOT work with mod_python handler for me.
When I open the page in a browser and check the Encoding from  the browser menu,
it is set to Western European(ISO) not to UTF-8.

Where can be a problem?
Thank you for hel
Lad.



More information about the Mod_python mailing list