Kevin Dangoor wrote: > > this error happens when the variable PAISCLIENTE contains caracter > > latin-1 > > > > "c:\python24\lib\site-packages\turbogears-0.8.8-py2.4.egg\turbogears\__init__.py", > > line 42, in url > > args = ["%s=%s" % (key, urllib.quote(str(value))) > > UnicodeEncodeError: 'ascii' codec can't encode characters in position > > 5-6: ordinal not in range(128) > > That particular problem has been in place for some time and appears to > still be there. That hasn't changed between 0.8a3 and 0.8.8, from what > I can see. > > I wonder if that should be urllib.quote(unicode(value)) rather than > urllib.quote(str(value)). My guess is that that would still cause > problems, because the data needs to be encoded in some form > that can then be url quoted...
RFC 2718 (http://www.faqs.org/rfcs/rfc2718.html) says UTF-8, so you should probably do s = urllib.quote(value.encode("utf-8")) on the way out, and preferrably s = urllib.unquote(value) try: s = unicode(s, "utf-8") except UnicodeDecodeError: pass # unknown encoding; leave as is on the way in (if relevant). </F>

