summaryrefslogtreecommitdiffstats
path: root/Doc/howto
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-11-25 11:57:17 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-11-25 11:57:17 (GMT)
commit166ebc4e5dd09f005c6144b7568da83728b8b893 (patch)
treef6b9deb3cb72095ef55bcef31637f4aaafe95248 /Doc/howto
parent6cecf68c7b51390429a2488846b1d0c29581987a (diff)
downloadcpython-166ebc4e5dd09f005c6144b7568da83728b8b893.zip
cpython-166ebc4e5dd09f005c6144b7568da83728b8b893.tar.gz
cpython-166ebc4e5dd09f005c6144b7568da83728b8b893.tar.bz2
Issue #19676: Added the "namereplace" error handler.
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 50bca5a..aac2373 100644
--- a/Doc/howto/unicode.rst
+++ b/Doc/howto/unicode.rst
@@ -325,8 +325,9 @@ The *errors* parameter is the same as the parameter of the
:meth:`~bytes.decode` method but supports a few more possible handlers. As well as
``'strict'``, ``'ignore'``, and ``'replace'`` (which in this case
inserts a question mark instead of the unencodable character), there is
-also ``'xmlcharrefreplace'`` (inserts an XML character reference) and
-``backslashreplace`` (inserts a ``\uNNNN`` escape sequence).
+also ``'xmlcharrefreplace'`` (inserts an XML character reference),
+``backslashreplace`` (inserts a ``\uNNNN`` escape sequence) and
+``namereplace`` (inserts a ``\N{...}`` escape sequence).
The following example shows the different results::
@@ -346,6 +347,8 @@ The following example shows the different results::
b'&#40960;abcd&#1972;'
>>> u.encode('ascii', 'backslashreplace')
b'\\ua000abcd\\u07b4'
+ >>> u.encode('ascii', 'namereplace')
+ b'\\N{YI SYLLABLE IT}abcd\\u07b4'
The low-level routines for registering and accessing the available
encodings are found in the :mod:`codecs` module. Implementing new