p8scii

Provides the p8scii encoding for translating strings to/from P8SCII.

Picopod automatically registers the encoding when you import it, but if you need to manually register it, use register().

picopod.p8scii.CHARACTERS

All P8SCII characters in byte order.

picopod.p8scii.CHARMAP

Mapping from Unicode code points to bytes.

picopod.p8scii.isascii(ch)

Return true if a character ordinal is the same in both P8SCII and ASCII.

picopod.p8scii.encode(input, errors='strict')

Encode a string to P8SCII bytes.

Parameters:
  • input (str) – The string to encode.

  • errors (str, optional) – The scheme to use for error handling. Defaults to “strict”.

Returns:

A (bytes, length consumed) tuple for the encoded data. The length consumed is always the length of the input.

picopod.p8scii.decode(input, errors='strict')

Decode a string from P8SCII bytes.

Parameters:
  • input (Buffer) – The bytes to decode.

  • errors (str, optional) – The scheme to use for error handling. Defaults to “strict”.

Returns:

A (string, length consumed) tuple for the decoded string. The length consumed is always the length of the input.

class picopod.p8scii.IncrementalEncoder(errors='strict')

Bases: IncrementalEncoder

P8SCII incremental encoder.

encode(input, final=False)

Encodes input and returns the resulting object.

class picopod.p8scii.IncrementalDecoder(errors='strict')

Bases: IncrementalDecoder

P8SCII incremental decoder.

decode(input, final=False)

Decode input and returns the resulting object.

class picopod.p8scii.Codec

Bases: Codec

P8SCII codec.

encode(input, errors='strict')

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.

decode(input, errors='strict')

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.

class picopod.p8scii.StreamWriter(stream, errors='strict')

Bases: Codec, StreamWriter

P8SCII stream writer.

class picopod.p8scii.StreamReader(stream, errors='strict')

Bases: Codec, StreamReader

P8SCII stream reader.

picopod.p8scii.getregentry()

Return the CodecInfo for the p8scii encoding.

picopod.p8scii.register()

Register the p8scii encoding if it is not present.