[mod_python] mod_python and unicode

Joshua Ginsberg listspam at flowtheory.net
Sun Jun 25 10:16:48 EDT 2006


I'll repeat my previous post...

http://mailman.modpython.org/pipermail/mod_python/2006-June/021447.html

For the love of God, please make sure you read:

http://www.joelonsoftware.com/articles/Unicode.html

and (shameless plug):

http://starboard.flowtheory.net/blog/?q=node/206

-jag


On Jun 25, 2006, at 8:10 AM, b3nder wrote:

> Hi, list.
>
> Tell me please how to use utf-8 in ouput?
>
> from mod_python         import apache
> import codecs
> import os
>
>
> def handler(req):
>     req.content_type = 'text/plain; charset=utf-8'
>     req.send_http_header()
>     file = codecs.open(
>         os.path.dirname(__file__) + "/myfile.txt", "r", "utf-8")
>     a = file.read()
>     req.write(a)
>
>     return apache.OK
>
>
> gives error UnicodeEncodeError: 'ascii' codec can't encode
> characters in position 0-5: ordinal not in range(128)
>
> Thanks.
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python



More information about the Mod_python mailing list