MCPcopy Create free account
hub / github.com/kurtmckee/feedparser / handle_charref

Method handle_charref

feedparser/html.py:218–235  ·  view source on GitHub ↗

:type ref: str :rtype: None

(self, ref)

Source from the content-addressed store, hash-verified

216 self.pieces.append("</%s>" % tag)
217
218 def handle_charref(self, ref):
219 """
220 :type ref: str
221 :rtype: None
222 """
223
224 # Called for each character reference, e.g. '&#160;' will extract '160'
225 # Reconstruct the original character reference.
226 ref = ref.lower()
227 if ref.startswith('x'):
228 value = int(ref[1:], 16)
229 else:
230 value = int(ref)
231
232 if value in _cp1252:
233 self.pieces.append('&#%s;' % hex(ord(_cp1252[value]))[1:])
234 else:
235 self.pieces.append('&#%s;' % ref)
236
237 def handle_entityref(self, ref):
238 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected