Show More
@@ -379,6 +379,16 b' class normcasespecs(object):' | |||||
379 | other = 0 |
|
379 | other = 0 | |
380 |
|
380 | |||
381 | _jsonmap = [] |
|
381 | _jsonmap = [] | |
|
382 | _jsonmap.extend("\\u%04x" % x for x in xrange(32)) | |||
|
383 | _jsonmap.extend(chr(x) for x in xrange(32, 256)) | |||
|
384 | _jsonmap[0x7f] = '\\u007f' | |||
|
385 | _jsonmap[0x09] = '\\t' | |||
|
386 | _jsonmap[0x0a] = '\\n' | |||
|
387 | _jsonmap[0x22] = '\\"' | |||
|
388 | _jsonmap[0x5c] = '\\\\' | |||
|
389 | _jsonmap[0x08] = '\\b' | |||
|
390 | _jsonmap[0x0c] = '\\f' | |||
|
391 | _jsonmap[0x0d] = '\\r' | |||
382 |
|
392 | |||
383 | def jsonescape(s): |
|
393 | def jsonescape(s): | |
384 | '''returns a string suitable for JSON |
|
394 | '''returns a string suitable for JSON | |
@@ -407,18 +417,6 b' def jsonescape(s):' | |||||
407 | '' |
|
417 | '' | |
408 | ''' |
|
418 | ''' | |
409 |
|
419 | |||
410 | if not _jsonmap: |
|
|||
411 | _jsonmap.extend("\\u%04x" % x for x in xrange(32)) |
|
|||
412 | _jsonmap.extend(chr(x) for x in xrange(32, 256)) |
|
|||
413 | _jsonmap[0x7f] = '\\u007f' |
|
|||
414 | _jsonmap[0x09] = '\\t' |
|
|||
415 | _jsonmap[0x0a] = '\\n' |
|
|||
416 | _jsonmap[0x22] = '\\"' |
|
|||
417 | _jsonmap[0x5c] = '\\\\' |
|
|||
418 | _jsonmap[0x08] = '\\b' |
|
|||
419 | _jsonmap[0x0c] = '\\f' |
|
|||
420 | _jsonmap[0x0d] = '\\r' |
|
|||
421 |
|
||||
422 | return ''.join(_jsonmap[x] for x in bytearray(toutf8b(s))) |
|
420 | return ''.join(_jsonmap[x] for x in bytearray(toutf8b(s))) | |
423 |
|
421 | |||
424 | _utf8len = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 4] |
|
422 | _utf8len = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 4] |
General Comments 0
You need to be logged in to leave comments.
Login now