@@ -520,44 +520,46 @@ The base :class:`Codec` class defines these methods which also define the
520
520
function interfaces of the stateless encoder and decoder:
521
521
522
522
523
- .. method :: Codec.encode(input, errors='strict')
523
+ .. class :: Codec
524
524
525
- Encodes the object *input * and returns a tuple (output object, length consumed).
526
- For instance, :term: `text encoding ` converts
527
- a string object to a bytes object using a particular
528
- character set encoding (e.g., ``cp1252 `` or ``iso-8859-1 ``).
525
+ .. method :: encode(input, errors='strict')
529
526
530
- The *errors * argument defines the error handling to apply.
531
- It defaults to ``'strict' `` handling.
527
+ Encodes the object *input * and returns a tuple (output object, length consumed).
528
+ For instance, :term: `text encoding ` converts
529
+ a string object to a bytes object using a particular
530
+ character set encoding (e.g., ``cp1252 `` or ``iso-8859-1 ``).
532
531
533
- The method may not store state in the :class: `Codec ` instance. Use
534
- :class: `StreamWriter ` for codecs which have to keep state in order to make
535
- encoding efficient.
532
+ The *errors * argument defines the error handling to apply.
533
+ It defaults to ``'strict' `` handling.
536
534
537
- The encoder must be able to handle zero length input and return an empty object
538
- of the output object type in this situation.
535
+ The method may not store state in the :class: `Codec ` instance. Use
536
+ :class: `StreamWriter ` for codecs which have to keep state in order to make
537
+ encoding efficient.
539
538
539
+ The encoder must be able to handle zero length input and return an empty object
540
+ of the output object type in this situation.
540
541
541
- .. method :: Codec.decode(input, errors='strict')
542
542
543
- Decodes the object *input * and returns a tuple (output object, length
544
- consumed). For instance, for a :term: `text encoding `, decoding converts
545
- a bytes object encoded using a particular
546
- character set encoding to a string object.
543
+ .. method :: decode(input, errors='strict')
547
544
548
- For text encodings and bytes-to-bytes codecs,
549
- *input * must be a bytes object or one which provides the read-only
550
- buffer interface -- for example, buffer objects and memory mapped files.
545
+ Decodes the object *input * and returns a tuple (output object, length
546
+ consumed). For instance, for a :term: `text encoding `, decoding converts
547
+ a bytes object encoded using a particular
548
+ character set encoding to a string object.
551
549
552
- The *errors * argument defines the error handling to apply.
553
- It defaults to ``'strict' `` handling.
550
+ For text encodings and bytes-to-bytes codecs,
551
+ *input * must be a bytes object or one which provides the read-only
552
+ buffer interface -- for example, buffer objects and memory mapped files.
554
553
555
- The method may not store state in the :class: `Codec ` instance. Use
556
- :class: `StreamReader ` for codecs which have to keep state in order to make
557
- decoding efficient.
554
+ The *errors * argument defines the error handling to apply.
555
+ It defaults to ``'strict' `` handling.
558
556
559
- The decoder must be able to handle zero length input and return an empty object
560
- of the output object type in this situation.
557
+ The method may not store state in the :class: `Codec ` instance. Use
558
+ :class: `StreamReader ` for codecs which have to keep state in order to make
559
+ decoding efficient.
560
+
561
+ The decoder must be able to handle zero length input and return an empty object
562
+ of the output object type in this situation.
561
563
562
564
563
565
Incremental Encoding and Decoding
@@ -705,7 +707,7 @@ Stream Encoding and Decoding
705
707
706
708
The :class: `StreamWriter ` and :class: `StreamReader ` classes provide generic
707
709
working interfaces which can be used to implement new encoding submodules very
708
- easily. See :mod: `encodings.utf_8 ` for an example of how this is done.
710
+ easily. See :mod: `! encodings.utf_8 ` for an example of how this is done.
709
711
710
712
711
713
.. _stream-writer-objects :
@@ -895,9 +897,10 @@ The design is such that one can use the factory functions returned by the
895
897
.. class :: StreamRecoder(stream, encode, decode, Reader, Writer, errors='strict')
896
898
897
899
Creates a :class: `StreamRecoder ` instance which implements a two-way conversion:
898
- *encode * and *decode * work on the frontend — the data visible to
899
- code calling :meth: `read ` and :meth: `write `, while *Reader * and *Writer *
900
- work on the backend — the data in *stream *.
900
+ *encode * and *decode * work on the frontend — the data visible to
901
+ code calling :meth: `~StreamReader.read ` and :meth: `~StreamWriter.write `,
902
+ while *Reader * and *Writer *
903
+ work on the backend — the data in *stream *.
901
904
902
905
You can use these objects to do transparent transcodings, e.g., from Latin-1
903
906
to UTF-8 and back.
@@ -1417,8 +1420,10 @@ to :class:`bytes` mappings. They are not supported by :meth:`bytes.decode`
1417
1420
| | quotedprintable, | quoted printable. | ``quotetabs=True `` / |
1418
1421
| | quoted_printable | | :meth: `quopri.decode ` |
1419
1422
+----------------------+------------------+------------------------------+------------------------------+
1420
- | uu_codec | uu | Convert the operand using | :meth: `uu.encode ` / |
1421
- | | | uuencode. | :meth: `<
341A
span class="pl-s">uu.decode` |
1423
+ | uu_codec | uu | Convert the operand using | :meth: `!uu.encode ` / |
1424
+ | | | uuencode. | :meth: `!uu.decode ` |
1425
+ | | | | (Note: :mod: `uu ` is |
1426
+ | | | | deprecated.) |
1422
1427
+----------------------+------------------+------------------------------+------------------------------+
1423
1428
| zlib_codec | zip, zlib | Compress the operand using | :meth: `zlib.compress ` / |
1424
1429
| | | gzip. | :meth: `zlib.decompress ` |
0 commit comments