codecs.xmlcharrefreplace_errors
Prev: codecs.strict_errors | Up: codecs
Rel: codecs.backslashreplace_errors, codecs.Codec, codecs.CodecInfo, codecs.decode
Ref: docs.python.org — codecs.xmlcharrefreplace_errors
Tags: #public #python3 #stdlib #codecs
Import
import codecs
from codecs import xmlcharrefreplace_errors
Signature & Overview
codecs.xmlcharrefreplace_errors(self, object, /)
Implements the 'xmlcharrefreplace' error handling, which replaces an unencodable character with the appropriate XML character reference.
Usage
import codecs
assert "é".encode("ascii", errors="xmlcharrefreplace") == b"é"
Gotchas
- Encode-only handler: Replaces non-ASCII characters with numeric XML/HTML entities (
&#NNN;).
REPL Inspect
from codecs import xmlcharrefreplace_errors
help(xmlcharrefreplace_errors)
Linked from
Related notes
- tuts/python3/stdlib_module/codecs/strict_errors Linked here; links to this page; shared tags: #codecs, #stdlib
- tuts/python3/stdlib_module/codecs Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/codecs/backslashreplace_errors Linked here; shared tags: #codecs, #stdlib
- tuts/python3/stdlib_module/codecs/Codec Linked here; shared tags: #codecs, #stdlib
- tuts/python3/stdlib_module/codecs/CodecInfo Linked here; shared tags: #codecs, #stdlib
- tuts/python3/stdlib_module/codecs/decode Linked here; shared tags: #codecs, #stdlib
- tuts/python3/stdlib_module/codecs/encode shared tags: #codecs, #stdlib
- tuts/python3/stdlib_module/codecs/EncodedFile shared tags: #codecs, #stdlib
- tuts/python3/stdlib_module/codecs/getdecoder shared tags: #codecs, #stdlib
- tuts/python3/stdlib_module/codecs/getencoder shared tags: #codecs, #stdlib