On Mar 8, 2006, at 6:49 AM, Jonathan LaCour wrote:
> >> Write a test case so that other people can see the issue. > > Okay, I created a simple test case as a TurboGears 0.9a1 > application. It works fine in Firefox, but doesn't work properly in > Safari. You can download it at: > > http://cleverdevil.org/testcase.tar.gz > > I definitely could be doing something wrong, but if it works in one > browser and not another, that leads me to believe that its a bug in > the browser. Looks like it's a bug in TG somewhere.. simplejson does the right thing: >>> import simplejson >>> print simplejson.dumps(dict(text=u'\u00bfHabla espa\u00f1ol?')) {"text":"\u00bfHabla espa\u00f1ol?"} but TG does not: >>> import urllib >>> print urllib.urlopen('http://127.0.0.1:8080/test').read() {"tg_flash":null, "text":"¿Habla español?"} This is apparently Kevin's fault according to svn blame: 370 kevin class GenericJSON(JSONEncoder): 829 kevin def __init__(self): 829 kevin super(GenericJSON, self).__init__ (ensure_ascii = False) In this revision: http://trac.turbogears.org/turbogears/changeset/829 Supposedly this "helps" non-ascii characters through JSON, but it doesn't have the intended result. The right fix for #430 would've been to ensure unicode strings from browser input, instead of ensuring potential garbage makes its way into the JSON output. In this case, it would be a change to the way URLs (at least the query string) are handled. This could be fixed by making cherrypy.lib.parseQueryString look at the resultant dict for keys that are outside of ASCII and decoding them to UTF-8... or it could be done as a filter like the formencode NestedVariablesFilter in startup. -bob --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

