|
Gregory (Grisha) Trubetskoy
grisha at modpython.org
Thu Jun 24 21:54:27 EDT 2004
On Thu, 24 Jun 2004, Jon-Pierre Gentil wrote:
>> and turn off UTF-8, unless you really need unicode support then that
>> won't help ;-)
>
> It's not, though. It's done in mod_python, in the Publisher, line 143
> of publisher.py. :) If I use my own handler it works great, I can
> output UTF-8 or UTF-16 or any other character set. For some reason the
> publisher tries to convert it to ascii.
I'm somewhat unicode illeterate, so this is probably why I never ran into
any problems with this.
But here is an idea - str() simply calls the object's __str__ method - so
why not subclass unicode and implement a __str__ that would produce UTF?
Something like this:
class MyUnicode(unicode):
def __str__(self):
return self.encode('utf-8')
def unicode(req):
req.content_type = 'text/html; charset=UTF-8'
return MyUnicode(u"Hello\u1234World!")
Grisha
|