@@ -895,16 +895,36 @@ are always available. They are listed here in alphabetical order.
895895 the list of supported encodings.
896896
897897 *errors * is an optional string that specifies how encoding and decoding
898- errors are to be handled--this cannot be used in binary mode. Pass
899- ``'strict' `` to raise a :exc: `ValueError ` exception if there is an encoding
900- error (the default of ``None `` has the same effect), or pass ``'ignore' `` to
901- ignore errors. (Note that ignoring encoding errors can lead to data loss.)
902- ``'replace' `` causes a replacement marker (such as ``'?' ``) to be inserted
903- where there is malformed data. When writing, ``'xmlcharrefreplace' ``
904- (replace with the appropriate XML character reference) or
905- ``'backslashreplace' `` (replace with backslashed escape sequences) can be
906- used. Any other error handling name that has been registered with
907- :func: `codecs.register_error ` is also valid.
898+ errors are to be handled--this cannot be used in binary mode.
899+ A variety of standard error handlers are available, though any
900+ error handling name that has been registered with
901+ :func: `codecs.register_error ` is also valid. The standard names
902+ are:
903+
904+ * ``'strict' `` to raise a :exc: `ValueError ` exception if there is
905+ an encoding error. The default value of ``None `` has the same
906+ effect.
907+
908+ * ``'ignore' `` ignores errors. Note that ignoring encoding errors
909+ can lead to data loss.
910+
911+ * ``'replace' `` causes a replacement marker (such as ``'?' ``) to be inserted
912+ where there is malformed data.
913+
914+ * ``'surrogateescape' `` will represent any incorrect bytes as code
915+ points in the Unicode Private Use Area ranging from U+DC80 to
916+ U+DCFF. These private code points will then be turned back into
917+ the same bytes when the ``surrogateescape `` error handler is used
918+ when writing data. This is useful for processing files in an
919+ unknown encoding.
920+
921+ * ``'xmlcharrefreplace' `` is only supported when writing to a file.
922+ Characters not supported by the encoding are replaced with the
923+ appropriate XML character reference ``&#nnn; ``.
924+
925+ * ``'backslashreplace' `` (also only supported when writing)
926+ replaces unsupported characters with Python's backslashed escape
927+ sequences.
908928
909929 .. index ::
910930 single: universal newlines; open() built-in function
0 commit comments