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