summaryrefslogtreecommitdiffstats
path: root/Doc/howto
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-01-25 20:56:57 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-01-25 20:56:57 (GMT)
commit07985ef387a87486a0e632844be03a8877e7f889 (patch)
treeb89d636e8ba7b0cd170064698741aebb46951eb5 /Doc/howto
parent58f02019e0a772b5689b69182f4f162666657294 (diff)
downloadcpython-07985ef387a87486a0e632844be03a8877e7f889.zip
cpython-07985ef387a87486a0e632844be03a8877e7f889.tar.gz
cpython-07985ef387a87486a0e632844be03a8877e7f889.tar.bz2
Issue #22286: The "backslashreplace" error handlers now works with
decoding and translating.
Diffstat (limited to 'Doc/howto')
-rw-r--r--Doc/howto/unicode.rst7
1 files changed, 5 insertions, 2 deletions
diff --git a/Doc/howto/unicode.rst b/Doc/howto/unicode.rst
index 5ea311e..ee31a9c 100644
--- a/Doc/howto/unicode.rst
+++ b/Doc/howto/unicode.rst
@@ -280,8 +280,9 @@ and optionally an *errors* argument.
The *errors* argument specifies the response when the input string can't be
converted according to the encoding's rules. Legal values for this argument are
``'strict'`` (raise a :exc:`UnicodeDecodeError` exception), ``'replace'`` (use
-``U+FFFD``, ``REPLACEMENT CHARACTER``), or ``'ignore'`` (just leave the
-character out of the Unicode result).
+``U+FFFD``, ``REPLACEMENT CHARACTER``), ``'ignore'`` (just leave the
+character out of the Unicode result), or ``'backslashreplace'`` (inserts a
+``\xNN`` escape sequence).
The following examples show the differences::
>>> b'\x80abc'.decode("utf-8", "strict") #doctest: +NORMALIZE_WHITESPACE
@@ -291,6 +292,8 @@ The following examples show the differences::
invalid start byte
>>> b'\x80abc'.decode("utf-8", "replace")
'\ufffdabc'
+ >>> b'\x80abc'.decode("utf-8", "backslashreplace")
+ '\\x80abc'
>>> b'\x80abc'.decode("utf-8", "ignore")
'abc'