changeset 11891:0bedf3a2062a stable

templatefilters: unnest uescape()
author Patrick Mezard <pmezard@gmail.com>
date Sun, 15 Aug 2010 17:50:52 +0200
parents 9dac951d0185
children 2be70ca17311
files mercurial/templatefilters.py
diffstat 1 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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):