From f1fcb886a04cd781f3913da6115e13c11456cb40 Mon Sep 17 00:00:00 2001 From: Michele Comitini Date: Sat, 22 Sep 2012 23:10:07 +0200 Subject: [PATCH] utf-8 entities pre-encoding speedup. --- gluon/html.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gluon/html.py b/gluon/html.py index 95990cd7..362b8597 100644 --- a/gluon/html.py +++ b/gluon/html.py @@ -32,7 +32,7 @@ regex_crlf = re.compile('\r|\n') join = ''.join -entitydefs = dict(map(lambda (k,v): (k, unichr(v)), name2codepoint.iteritems())) +entitydefs = dict(map(lambda (k,v): (k, unichr(v).encode('utf-8')), name2codepoint.iteritems())) entitydefs.setdefault('apos', u"'") @@ -2408,7 +2408,7 @@ class web2pyHTMLParser(HTMLParser): else: self.parent.append(unichr(int(name)).encode('utf8')) def handle_entityref(self,name): - self.parent.append(entitydefs[name].encode('utf8')) + self.parent.append(entitydefs[name]) def handle_endtag(self, tagname): # this deals with unbalanced tags if tagname==self.last: