codecs.backslashreplace_errors
Up: codecs | Next: codecs.Codec
Rel: codecs.Codec, codecs.CodecInfo, codecs.decode, codecs.encode
Ref: docs.python.org — codecs.backslashreplace_errors
Tags: #public #python3 #stdlib #codecs
Import
import codecs
from codecs import backslashreplace_errors
Signature & Overview
codecs.backslashreplace_errors(self, object, /)
Implements the 'backslashreplace' error handling, which replaces malformed data with a backslashed escape sequence.
Usage
import codecs
assert "café".encode("ascii", errors="backslashreplace") == b"caf\\xe9"
assert codecs.lookup_error("backslashreplace") is codecs.backslashreplace_errors
Gotchas
- Lossless ASCII fallback: Works for both encoding and decoding.
REPL Inspect
from codecs import backslashreplace_errors
help(backslashreplace_errors)
Linked from
- tuts/python3/stdlib_module/codecs
- tuts/python3/stdlib_module/codecs/Codec
- tuts/python3/stdlib_module/codecs/CodecInfo
- tuts/python3/stdlib_module/codecs/decode
- tuts/python3/stdlib_module/codecs/encode
- tuts/python3/stdlib_module/codecs/EncodedFile
- tuts/python3/stdlib_module/codecs/getdecoder
- tuts/python3/stdlib_module/codecs/getencoder
- tuts/python3/stdlib_module/codecs/getincrementaldecoder
- tuts/python3/stdlib_module/codecs/getincrementalencoder
- tuts/python3/stdlib_module/codecs/getreader
- tuts/python3/stdlib_module/codecs/getwriter
- tuts/python3/stdlib_module/codecs/ignore_errors
- tuts/python3/stdlib_module/codecs/IncrementalDecoder
- tuts/python3/stdlib_module/codecs/IncrementalEncoder
- tuts/python3/stdlib_module/codecs/iterdecode
- tuts/python3/stdlib_module/codecs/iterencode
- tuts/python3/stdlib_module/codecs/lookup
- tuts/python3/stdlib_module/codecs/lookup_error
- tuts/python3/stdlib_module/codecs/namereplace_errors
- tuts/python3/stdlib_module/codecs/open
- tuts/python3/stdlib_module/codecs/register
- tuts/python3/stdlib_module/codecs/register_error
- tuts/python3/stdlib_module/codecs/replace_errors
- tuts/python3/stdlib_module/codecs/StreamReader
- tuts/python3/stdlib_module/codecs/StreamReaderWriter
- tuts/python3/stdlib_module/codecs/StreamRecoder
- tuts/python3/stdlib_module/codecs/StreamWriter
- tuts/python3/stdlib_module/codecs/strict_errors
- tuts/python3/stdlib_module/codecs/xmlcharrefreplace_errors
Related notes
- tuts/python3/stdlib_module/codecs/Codec Linked here; links to this page; shared tags: #codecs, #stdlib
- tuts/python3/stdlib_module/codecs/CodecInfo Linked here; links to this page; shared tags: #codecs, #stdlib
- tuts/python3/stdlib_module/codecs/decode Linked here; links to this page; shared tags: #codecs, #stdlib
- tuts/python3/stdlib_module/codecs/encode 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/EncodedFile links to this page; shared tags: #codecs, #stdlib
- tuts/python3/stdlib_module/codecs/getdecoder links to this page; shared tags: #codecs, #stdlib
- tuts/python3/stdlib_module/codecs/getencoder links to this page; shared tags: #codecs, #stdlib
- tuts/python3/stdlib_module/codecs/getincrementaldecoder links to this page; shared tags: #codecs, #stdlib
- tuts/python3/stdlib_module/codecs/getincrementalencoder links to this page; shared tags: #codecs, #stdlib