Example #1
0
 def encode(char):
   char = ord(char)
   name = codepoint2name.get(char)
   if name is not None:
     return "&%s;" % name
   else:
     return "%%%02X" % char
 def encode(char):
   char = ord(char)
   name = codepoint2name.get(char)
   if name is not None:
     return "&%s;" % name
   else:
     return "%%%02X" % char
Example #3
0
def escapize(char):
    a = codepoint2name.get(ord(char), None)
    if a:
        return '&' + a + ';'
    return char
Example #4
0
def html_replace(exc):
	assert isinstance(exc, (UnicodeEncodeError, UnicodeTranslateError))
	s = [ u'&%s;' % codepoint2name.get(ord(c), '#x%04X' % (ord(c),))
			for c in exc.object[exc.start:exc.end] ]
	return ''.join(s), exc.end
Example #5
0
 def html_entity(self):
     name = codepoint2name.get(self.dec)
     if name:
         return '&%s;' % name
     else:
         return ''
Example #6
0
def escapize(char):
    a = codepoint2name.get(ord(char), None)
    if a:
        return '&' + a + ';'
    return char