List Info

Thread: unocde error with cherrypy




unocde error with cherrypy
user name
2006-03-30 18:23:31
pytrade wrote:
> I have a Restr string which I'm converting to HTML
throguh docstring:
> I'm getting the following error from cherrypy:
> 
> 30/Mar/2006:05:47:31  INFO Page handler: 'ordinal not
in range(128)'
> Traceback (most recent call last):
>   File
>
"/usr/lib/python2.4/site-packages/CherryPy-2.2.0rc1-py
2.4.egg/
cherrypy/_cpwsgi.py",
> line 96, in wsgiApp
>     chunk = str(chunk)
> UnicodeEncodeError: 'ascii' codec can't encode
character u'\x92' in
> position 15625: ordinal not in range(128)
> 
> When I googled for u'\x92' it turns out to be a LEFT
SINGLE QUOTATION
> MARK. Is there a work around somewhere?

Coerce your output to a string before your return it from
your page
handler. That can be as simple as:

    output = output.encode("utf8")
    return output

...at the bottom of your page handler.

Another option is to use the encoding filter. But keep in
mind that the
encoding filter only encodes output if the Content-Type
starts with
"text/" (we should probably make that
configurable).


Robert Brewer
System Architect
Amor Ministries
fumanchuamor.org

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-usersgooglegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribegooglegroups.com
For more options, visit this group at http://
groups.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---

unocde error with cherrypy
user name
2006-03-30 20:24:11
Thanks using .encode("utf8") fixed the problem.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-usersgooglegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribegooglegroups.com
For more options, visit this group at http://
groups.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )