summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2014-04-30 19:16:17 +0200
committerJon Bergli Heier <snakebite@jvnv.net>2014-04-30 19:16:17 +0200
commit772cd8499167ca3740d3e705256c35d4da4da362 (patch)
tree29b512d6b51ce78d04750083e5b38901d02aec87
parent82024b1352c667532245a36cd6361ba7a7e44d36 (diff)
wacalc: Handle escaped unicode characters.
-rw-r--r--modules/wacalc.py2
1 files changed, 2 insertions, 0 deletions
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']