Show More
@@ -148,7 +148,13 b' def xmlescape(text):' | |||
|
148 | 148 | def jsonescape(s): |
|
149 | 149 | for k, v in _escapes: |
|
150 | 150 | s = s.replace(k, v) |
|
151 | return s | |
|
151 | ||
|
152 | def uescape(c): | |
|
153 | if ord(c) < 0x80: | |
|
154 | return c | |
|
155 | else: | |
|
156 | return '\\u%04x' % ord(c) | |
|
157 | return ''.join(uescape(c) for c in s) | |
|
152 | 158 | |
|
153 | 159 | def json(obj): |
|
154 | 160 | if obj is None or obj is False or obj is True: |
@@ -157,9 +163,9 b' def json(obj):' | |||
|
157 | 163 | return str(obj) |
|
158 | 164 | elif isinstance(obj, str): |
|
159 | 165 | u = unicode(obj, encoding.encoding, 'replace') |
|
160 |
return '"%s"' % jsonescape(u) |
|
|
166 | return '"%s"' % jsonescape(u) | |
|
161 | 167 | elif isinstance(obj, unicode): |
|
162 |
return '"%s"' % jsonescape(obj) |
|
|
168 | return '"%s"' % jsonescape(obj) | |
|
163 | 169 | elif hasattr(obj, 'keys'): |
|
164 | 170 | out = [] |
|
165 | 171 | for k, v in obj.iteritems(): |
@@ -984,5 +984,5 b' ul#graphnodes li .info {' | |||
|
984 | 984 | } |
|
985 | 985 | % Stop and restart with HGENCODING=cp932 |
|
986 | 986 | % Graph json escape of multibyte character |
|
987 |
var data = [["40b4d6888e92", [0, 1], [[0, 0, 1]], " |
|
|
987 | var data = [["40b4d6888e92", [0, 1], [[0, 0, 1]], "\u80fd", "test", "1970-01-01", ["stable", true], ["tip"]], ["1d22e65f027e", [0, 1], [[0, 0, 1]], "branch", "test", "1970-01-01", ["stable", false], []], ["a4f92ed23982", [0, 1], [[0, 0, 1]], "Added tag 1.0 for changeset 2ef0ac749a14", "test", "1970-01-01", ["default", true], []], ["2ef0ac749a14", [0, 1], [], "base", "test", "1970-01-01", ["default", false], ["1.0"]]]; | |
|
988 | 988 | % ERRORS ENCOUNTERED |
General Comments 0
You need to be logged in to leave comments.
Login now