codecs.namereplace_errors
Prev: codecs.lookup_error | Up: codecs | Next: codecs.open
Rel: codecs.backslashreplace_errors, codecs.Codec, codecs.CodecInfo, codecs.decode
Ref: docs.python.org — codecs.namereplace_errors
Tags: #public #python3 #stdlib #codecs
Import
import codecs
from codecs import namereplace_errors
Signature & Overview
codecs.namereplace_errors(self, object, /)
Implements the 'namereplace' error handling, which replaces an unencodable character with a \N{...} escape sequence.
Usage
import codecs
assert "é".encode("ascii", errors="namereplace") == b"\\N{LATIN SMALL LETTER E WITH ACUTE}"
Gotchas
- Encode-only handler: Replaces unencodable characters with
\N{UNICODE NAME}.
REPL Inspect
from codecs import namereplace_errors
help(namereplace_errors)
Linked from
Related notes
- tuts/python3/stdlib_module/codecs/lookup_error Linked here; links to this page; shared tags: #codecs, #stdlib
- tuts/python3/stdlib_module/codecs/open 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