From 772cd8499167ca3740d3e705256c35d4da4da362 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Wed, 30 Apr 2014 19:16:17 +0200 Subject: wacalc: Handle escaped unicode characters. --- modules/wacalc.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/wacalc.py b/modules/wacalc.py index 27d6962..dd1cf31 100644 --- a/modules/wacalc.py +++ b/modules/wacalc.py @@ -8,6 +8,7 @@ import urllib, urllib2, re from xml.etree.ElementTree import ElementTree whitespace_re = re.compile(r'\s+') +unicode_re = re.compile(r'(\\:[\da-f]{4})') class Module(object): config_section = 'module/wacalc' @@ -59,6 +60,7 @@ class Module(object): if result is not None and result.text is not None: text = result.text text = whitespace_re.sub(' ', text) + text = unicode_re.sub(lambda match: unichr(int(match.group()[2:], 16)), text) return text.encode('utf-8') for pod in xml.findall('pod'): pod_id = pod.attrib['id'] -- cgit v1.2.3