Some of the data I return from web2py is unicode.  By default, the
text that is return is converted to str:

"Table d'h\u00f4te"

As you can see, the unicode has been escaped.   This happens because
simplejson.dumps always returns str.   To solve this, I had to do
this:

    import gluon.contrib.simplejson as simplejson
    return unicode(simplejson.dumps(make_result_list(msg_out, rows,
success)), 'unicode-escape')

"Table d'hôte"

I attempted to put my code into serializers.py (the json() method),
but webpy would fail to start up for some reason that I don't have the
time to investigate further.  This isn't an error, because the
behaviour of simplejson.dumps is documented, but it was certainly a
gotcha in the sense that it took me a few hours to figure out what was
happening.

Reply via email to