utf-8 entities pre-encoding speedup.
This commit is contained in:
1 parent
7b373ecb71
commit
f1fcb886a0
1 file changed
+2
-2
+2
-2
@@ -32,7 +32,7 @@ regex_crlf = re.compile('\r|\n')
|
|||||||
|
|
||||||
join = ''.join
|
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"'")
|
entitydefs.setdefault('apos', u"'")
|
||||||
|
|
||||||
|
|
||||||
@@ -2408,7 +2408,7 @@ class web2pyHTMLParser(HTMLParser):
|
|||||||
else:
|
else:
|
||||||
self.parent.append(unichr(int(name)).encode('utf8'))
|
self.parent.append(unichr(int(name)).encode('utf8'))
|
||||||
def handle_entityref(self,name):
|
def handle_entityref(self,name):
|
||||||
self.parent.append(entitydefs[name].encode('utf8'))
|
self.parent.append(entitydefs[name])
|
||||||
def handle_endtag(self, tagname):
|
def handle_endtag(self, tagname):
|
||||||
# this deals with unbalanced tags
|
# this deals with unbalanced tags
|
||||||
if tagname==self.last:
|
if tagname==self.last:
|
||||||
|
|||||||
Reference in new issue
Block a user