durusmail: quixote-users: Unicode support for Quixote 2
Unicode support for Quixote 2
2004-09-03
2004-09-03
2004-09-03
2004-09-03
Quixote / mod_python - test workflow?
2004-09-04
Re: R: [Quixote-users] Quixote / mod_python - test workflow?
single word attributes in html.htmltag()
2004-09-05
Re: single word attributes in html.htmltag()
2004-09-06
2004-09-04
2004-09-08
Python Best of Breed web app snippets / small webapps
2004-09-08
2004-09-10
2004-09-09
2004-09-09
2004-09-09
2004-09-09
Unicode support for Quixote 2
Marcin Wojdyr
2004-09-03
Neil Schemenauer wrote:
> On Fri, Sep 03, 2004 at 01:26:38PM +0200, Marcin Wojdyr wrote:
>> If there are non-ascii chars in PTL it doesn't work:
> [...]
>>   File "/usr/lib/python2.3/site-packages/quixote/http_response.py", line
>> 210, in set_body     self.body = unicode(body).encode(self.charset)
>> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position
>> 954:
>> ordinal not in range(128)
>
> You need to use unicode strings if you want to use non-ascii
> characters.

Thanks for your reply, but I think I need more hints.
In demo/pages.ptl I added, at the beginning of _q_index following lines:
    request.response.set_charset(str('UTF-8'))
    unichr(0xf3)

and

Traceback (most recent call last):
  File "/usr/lib/python2.3/site-packages/quixote/publish.py", line 525, in
process_request
    output = self.try_publish(request, env.get('PATH_INFO', ''))
  File "/usr/lib/python2.3/site-packages/quixote/publish.py", line 458, in
try_publish
    output = object(request)
  File "/usr/lib/python2.3/site-packages/quixote/demo/pages.ptl", line 14,
in _q_index
    unichr(0xf3)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf3' in
position 0: ordinal not in range(128)

Could you give an minimal example of page with non-ascii characters,
that is encoded as set with set_charset()?

Marcin

--
Marcin Wojdyr  |  http://www.unipress.waw.pl/~wojdyr

reply