API Reference

Python Character Mapping Codec for T61

See https://en.wikipedia.org/wiki/ITU_T.61

class t61codec.Codec[source]

Bases: Codec

Main implementation for the T.61 codec, based on codecs.charmap_encode() and codecs.charmap_decode()

decode(input: str, errors: str = 'strict') tuple[str, int][source]

Decodes the object input and returns a tuple (output object, length consumed).

input must be an object which provides the bf_getreadbuf buffer slot. Python strings, buffer objects and memory mapped files are examples of objects providing this slot.

errors defines the error handling to apply. It defaults to ‘strict’ handling.

The method may not store state in the Codec instance. Use StreamReader for codecs which have to keep state in order to make decoding efficient.

The decoder must be able to handle zero length input and return an empty object of the output object type in this situation.

encode(input: str, errors: str = 'strict') tuple[bytes, int][source]

Encodes the object input and returns a tuple (output object, length consumed).

errors defines the error handling to apply. It defaults to ‘strict’ handling.

The method may not store state in the Codec instance. Use StreamWriter for codecs which have to keep state in order to make encoding efficient.

The encoder must be able to handle zero length input and return an empty object of the output object type in this situation.

class t61codec.IncrementalDecoder(errors='strict')[source]

Bases: IncrementalDecoder

See codecs.IncrementalDecoder

decode(input: bytes, final: bool = False) str[source]

Decode input and returns the resulting object.

class t61codec.IncrementalEncoder(errors='strict')[source]

Bases: IncrementalEncoder

See codecs.IncrementalEncoder

encode(input: str, final: bool = False) bytes[source]

Encodes input and returns the resulting object.

class t61codec.StreamReader(stream, errors='strict')[source]

Bases: Codec, StreamReader

See codecs.StreamReader

class t61codec.StreamWriter(stream, errors='strict')[source]

Bases: Codec, StreamWriter

See codecs.StreamWriter

t61codec.getregentry() CodecInfo[source]

Creates a codecs.CodecInfo instance for use in the registry

t61codec.register() None[source]

Convenience function which registers a new default Python search function

Example:

>>> import t61codec
>>> t61codec.register()
>>> b'Hello T.61: \xe0'.decode('t.61')
'Hello T.61: Ω'
t61codec.search_function(encoding: str) CodecInfo[source]

A search function which can be used with codecs.register().

As a convenience, there is also register() in this module.