Skip to content

Commit 648042b

Browse files
committed
Add documentation for codecs.escape_encode() and codecs.escape_decode()
1 parent db47f4d commit 648042b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Doc/library/codecs.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,10 +1461,26 @@ to :class:`bytes` mappings. They are not supported by :meth:`bytes.decode`
14611461
| uu_codec | uu | Convert the operand using | |
14621462
| | | uuencode. | |
14631463
+----------------------+------------------+------------------------------+------------------------------+
1464+
| escape_codec | escape | Encode and decode byte | :func:`codecs.escape_encode` |
1465+
| | | sequences using escape | / |
1466+
| | | sequences, similar to | :func:`codecs.escape_decode` |
1467+
| | | :func:`repr` of bytes. | |
1468+
+----------------------+------------------+------------------------------+------------------------------+
14641469
| zlib_codec | zip, zlib | Compress the operand using | :meth:`zlib.compress` / |
14651470
| | | gzip. | :meth:`zlib.decompress` |
14661471
+----------------------+------------------+------------------------------+------------------------------+
14671472

1473+
.. function:: codecs.escape_encode(input, errors='strict')
1474+
1475+
Encode *input* using escape sequences. Similar to how :func:`repr` on bytes
1476+
produces escaped byte values. Returns a tuple of the encoded bytes and
1477+
the length consumed.
1478+
1479+
.. function:: codecs.escape_decode(input, errors='strict')
1480+
1481+
Decode *input* from escape sequences back to the original bytes.
1482+
Returns a tuple of the decoded bytes and the length consumed.
1483+
14681484
.. [#b64] In addition to :term:`bytes-like objects <bytes-like object>`,
14691485
``'base64_codec'`` also accepts ASCII-only instances of :class:`str` for
14701486
decoding

0 commit comments

Comments
 (0)