[EMAIL PROTECTED] wrote:
> Hi list,
>
> i am using site-package (webPy) that generates
> "UnicodeEncodeError: 'ascii' codec can't encode characters
> in position 0-6: ordinal not in range(128)".
It looks like your data contains unicode strings. When you call str() on
a unicode string it tries to encode it using the default encoding which
is usually ascii. If the string contains non-ascii characters this
attempt fails.
The solution is probably to encode your data yourself using the codec of
your choice, for example utf-8. I can't tell from the traceback where
the data comes from but you need to do something like
s = s.encode('utf-8')
Kent
>
> The full message is:
> Traceback (most recent call last):
> File "c:\python24\lib\site-packages\web.py", line 1786, in
> run_wsgi_app
> result = self.server.app(env, self.wsgi_start_response)
> File "c:\python24\lib\site-packages\web.py", line 1662, in
> wsgifunc
> result = func()
> File "c:\python24\lib\site-packages\web.py", line 1642, in
> <lambda>
> func = lambda: handle(inp, fvars)
> File "c:\python24\lib\site-packages\web.py", line 920, in
> handle
> return tocall(*([urllib.unquote(x) for x in args] +
> fna))
> File "wb03.py", line 24, in GET
> web.render('view.html')
> File "c:\python24\lib\site-packages\web.py", line 1543, in
> render
> return output(str(compiled_tmpl))
> File "c:\Python24\Lib\site-packages\Cheetah\Template.py",
> line 990, in __str__
> def __str__(self): return getattr(self, mainMethName)()
> File "<string>", line 93, in respond
> File "c:\python24\lib\site-packages\web.py", line 1496, in
> filter
> return htmlquote(str(val))
> UnicodeEncodeError: 'ascii' codec can't encode characters in
> position 0-6: ordinal not in range(128)
>
>
> So, how can i fix this (from outside of this package)? The
> attempt with "# -*- coding: utf-8 -*-" does not solve this
> problem...
>
>
> cheers
> -e-
>
>
> -----------------------------
>
> Виж това УНИКАЛНО предложение :-)
> Хостинг на НЕВЕРОЯТНА ЦЕНА - 1,50 лв./месец!
> www.SuperHosting.bg - Динамичните Хостинг Решения
>
>
> _______________________________________________
> Tutor maillist - [email protected]
> http://mail.python.org/mailman/listinfo/tutor
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor