You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mod_python-dev@quetz.apache.org by Anders Blomdell <an...@control.lth.se> on 2010/03/05 09:59:01 UTC

Mod_python and unicode

Would it make sense to switch mod_python to always use unicode, as it is now,
publisher supports unicode content, but req.write and FieldList does use
bytestrings.

/Anders

-- 
Anders Blomdell                  Email: anders.blomdell@control.lth.se
Department of Automatic Control
Lund University                  Phone:    +46 46 222 4625
P.O. Box 118                     Fax:      +46 46 138118
SE-221 00 Lund, Sweden

Re: Mod_python and unicode

Posted by Graham Dumpleton <gr...@gmail.com>.
On 5 March 2010 19:59, Anders Blomdell <an...@control.lth.se> wrote:
> Would it make sense to switch mod_python to always use unicode,

No.

> as it is now,
> publisher supports unicode content, but req.write and FieldList does use
> bytestrings.

How is mod_python supposed to automagically know what is the correct
charset to use on request content and response content. It can't, only
your web application will know for certain. Even now with publisher,
you should not be relying on the fact that unicode response content is
converted to bytes automatically. If you do, then your code will not
be portable because if run on a system where the default encoding is
something different, it will break. This is because when you return
unicode, it is applying the default encoding.

Graham