MrQuantum wrote:
> I encounter the error
> ...
> File "/var/lib/python-support/python2.4/cherrypy/lib/httptools.py",
> line 468, in sorted_list
> header_list.append((order, (key, str(value))))
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xc4' in
> position 22: ordinal not in range(128)
>
> when calling the save method with a 'pagename' including german
> language characters (like ö, ä, ..)
This is a bug in CherryPy 2.2 and prior; it's been fixed for CherryPy 3
but not backported yet. Header output should be iso-8859-1; any
characters outside that set should be MIME-encoded. You can duplicate
the CP 3 logic by hand if you know your header has non-ASCII
characters:
# HTTP/1.0 says, "Words of *TEXT may contain octets
# from character sets other than US-ASCII." and
# "Recipients of header field TEXT containing octets
# outside the US-ASCII character set may assume that
# they represent ISO-8859-1 characters."
try:
v = v.encode("iso-8859-1")
except UnicodeEncodeError:
if cherrypy.response.protocol >= (1, 1):
# Encode RFC-2047 TEXT
# (e.g. u"\u8200" -> "=?utf-8?b?6IiA?=").
v = email.Header.Header(v, 'utf-8').encode()
else:
raise
Robert Brewer
System Architect
Amor Ministries
[EMAIL PROTECTED]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---