Unicode/UTF-8 confusion

Carsten Haese carsten at uniqsys.com
Sat Mar 15 15:03:11 EDT 2008


On Sat, 2008-03-15 at 12:09 -0400, Tom Stambaugh wrote:
> [...]
> I use simplejson to serialize html strings that the server is delivering to 
> a browser. Since the apostrophe is a string terminator in javascript, I need 
> to escape any apostrophe embedded in the html.
> [...]

simplejson escapes them for you:

>>> import simplejson
>>> s = "    '    "
>>> simplejson.dumps(s)
'"    \'    "'

Why is this not good enough for your needs?

-- 
Carsten Haese
http://informixdb.sourceforge.net





More information about the Python-list mailing list