UnicodeDecodeError when chameleon.zpt contains Chinese character

110 views
Skip to first unread message

Geo

unread,
May 4, 2012, 12:33:22 AM5/4/12
to pylons-...@googlegroups.com
Hi forks,

I'm getting "UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 0: ordinal not in range(128)" when I include Chinese character in the chameleon template. I'm using the newest pyramid 1.3 with python2.7. Any help?

Thanks

George Hu

Geo

unread,
May 4, 2012, 12:43:59 AM5/4/12
to pylons-...@googlegroups.com
Found the solution, just make sure you are always using the unicode string something like u'xxxxx'.

Malthe Borch

unread,
May 4, 2012, 4:24:09 AM5/4/12
to pylons-...@googlegroups.com
On 4 May 2012 06:33, Geo <geo...@gmail.com> wrote:
> I'm getting "UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in
> position 0: ordinal not in range(128)" when I include Chinese character in
> the chameleon template. I'm using the newest pyramid 1.3 with python2.7. Any
> help?

You need to specify an encoding if you want to include encoded
<str>'s, e.g. "utf-8".

It's an argument to the template renderer factory.

\malthe
Reply all
Reply to author
Forward
0 new messages