##// END OF EJS Templates
encoding: change jsonmap to a list indexed by code point...
Yuya Nishihara -
r28066:d1cc0712 default
parent child Browse files
Show More
@@ -378,7 +378,7 b' class normcasespecs(object):'
378 upper = 1
378 upper = 1
379 other = 0
379 other = 0
380
380
381 _jsonmap = {}
381 _jsonmap = []
382
382
383 def jsonescape(s):
383 def jsonescape(s):
384 '''returns a string suitable for JSON
384 '''returns a string suitable for JSON
@@ -408,21 +408,18 b' def jsonescape(s):'
408 '''
408 '''
409
409
410 if not _jsonmap:
410 if not _jsonmap:
411 for x in xrange(32):
411 _jsonmap.extend("\\u%04x" % x for x in xrange(32))
412 _jsonmap[chr(x)] = "\\u%04x" % x
412 _jsonmap.extend(chr(x) for x in xrange(32, 256))
413 for x in xrange(32, 256):
413 _jsonmap[0x7f] = '\\u007f'
414 c = chr(x)
414 _jsonmap[0x09] = '\\t'
415 _jsonmap[c] = c
415 _jsonmap[0x0a] = '\\n'
416 _jsonmap['\x7f'] = '\\u007f'
416 _jsonmap[0x22] = '\\"'
417 _jsonmap['\t'] = '\\t'
417 _jsonmap[0x5c] = '\\\\'
418 _jsonmap['\n'] = '\\n'
418 _jsonmap[0x08] = '\\b'
419 _jsonmap['\"'] = '\\"'
419 _jsonmap[0x0c] = '\\f'
420 _jsonmap['\\'] = '\\\\'
420 _jsonmap[0x0d] = '\\r'
421 _jsonmap['\b'] = '\\b'
422 _jsonmap['\f'] = '\\f'
423 _jsonmap['\r'] = '\\r'
424
421
425 return ''.join(_jsonmap[c] for c in toutf8b(s))
422 return ''.join(_jsonmap[x] for x in bytearray(toutf8b(s)))
426
423
427 _utf8len = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 4]
424 _utf8len = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 4]
428
425
General Comments 0
You need to be logged in to leave comments. Login now