Skip to content

Commit dc9d790

Browse files
authored
Add documentation for codecs.escape_encode() and codecs.escape_decode()
1 parent d1d5dce commit dc9d790

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
@@ -1443,10 +1443,26 @@ to :class:`bytes` mappings. They are not supported by :meth:`bytes.decode`
14431443
| uu_codec | uu | Convert the operand using | |
14441444
| | | uuencode. | |
14451445
+----------------------+------------------+------------------------------+------------------------------+
1446+
| escape_codec | escape | Encode and decode byte | :func:`codecs.escape_encode` |
1447+
| | | sequences using escape | / |
1448+
| | | sequences, similar to | :func:`codecs.escape_decode` |
1449+
| | | :func:`repr` of bytes. | |
1450+
+----------------------+------------------+------------------------------+------------------------------+
14461451
| zlib_codec | zip, zlib | Compress the operand using | :meth:`zlib.compress` / |
14471452
| | | gzip. | :meth:`zlib.decompress` |
14481453
+----------------------+------------------+------------------------------+------------------------------+
14491454

1455+
.. function:: codecs.escape_encode(input, errors='strict')
1456+
1457+
Encode *input* using escape sequences. Similar to how :func:`repr` on bytes
1458+
produces escaped byte values. Returns a tuple of the encoded bytes and
1459+
the length consumed.
1460+
1461+
.. function:: codecs.escape_decode(input, errors='strict')
1462+
1463+
Decode *input* from escape sequences back to the original bytes.
1464+
Returns a tuple of the decoded bytes and the length consumed.
1465+
14501466
.. [#b64] In addition to :term:`bytes-like objects <bytes-like object>`,
14511467
``'base64_codec'`` also accepts ASCII-only instances of :class:`str` for
14521468
decoding

0 commit comments

Comments
 (0)