templatefilters: unnest uescape() stable
authorPatrick Mezard <pmezard@gmail.com>
Sun, 15 Aug 2010 17:50:52 +0200
branchstable
changeset 11891 0bedf3a2062a
parent 11890 9dac951d0185
child 11892 2be70ca17311
templatefilters: unnest uescape()
mercurial/templatefilters.py
--- a/mercurial/templatefilters.py	Wed Aug 11 01:06:21 2010 +0900
+++ b/mercurial/templatefilters.py	Sun Aug 15 17:50:52 2010 +0200
@@ -140,6 +140,12 @@
             .replace("'", '&#39;')) # &apos; invalid in HTML
     return re.sub('[\x00-\x08\x0B\x0C\x0E-\x1F]', ' ', text)
 
+def uescape(c):
+    if ord(c) < 0x80:
+        return c
+    else:
+        return '\\u%04x' % ord(c)
+
 _escapes = [
     ('\\', '\\\\'), ('"', '\\"'), ('\t', '\\t'), ('\n', '\\n'),
     ('\r', '\\r'), ('\f', '\\f'), ('\b', '\\b'),
@@ -148,12 +154,6 @@
 def jsonescape(s):
     for k, v in _escapes:
         s = s.replace(k, v)
-
-    def uescape(c):
-        if ord(c) < 0x80:
-            return c
-        else:
-            return '\\u%04x' % ord(c)
     return ''.join(uescape(c) for c in s)
 
 def json(obj):