Encoding troubles

Xaver Hinterhuber xaver_hinterhuber at web.de
Tue May 18 02:37:08 EDT 2004


Hi Peter,

"Peter Otten" <__peter__ at web.de> schrieb im Newsbeitrag
news:c8anks$tq3$07$1 at news.t-online.com...
[snip]

> What does HTML() do? Are there any non-unicode strings with non-ascii
> characters that you try to concatenate with content? E. g.:

HTML is a zope class which handles dtml-markup.

> >>> u"äöü" + u"äöü"
> u'\xe4\xf6\xfc\xe4\xf6\xfc'
> >>> "äöü" + "äöü"
> '\xe4\xf6\xfc\xe4\xf6\xfc'
>
> But
>
> >>> u"äöü" + "äöü"
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 0:
> ordinal not in range(128)
>
> The solution is to make sure that either all strings are unicode or all
> strings are non-unicode (hopefully sharing the same encoding).

This was the problem.

Thank you very much for your help.


-- 
with kind regards
Xaver Hinterhuber





More information about the Python-list mailing list