codec

class naz.codec.GSM7BitCodec[source]

Bases: codecs.Codec

SMPP uses a 7-bit GSM character set. This class implements that encoding/decoding scheme. Users should never have to use this directly, instead; use naz.protocol.SubmitSM(encoding=”gsm0338”)

Example Usage:

import naz

codec = naz.codec.GSM7BitCodec()
codec.encode("foo €")
static decode(input, errors='strict')[source]

return a string decoded from the given bytes and its length.

Parameters
  • input (bytes) – the bytes to decode

  • errors (str) – same meaning as the errors argument to pythons’ encode method

Return type

Tuple[str, int]

static encode(input, errors='strict')[source]

return an encoded version of the string as a bytes object and its length.

Parameters
  • input (str) – the string to encode

  • errors (str) –

    same meaning as the errors argument to pythons’ encode method

Return type

Tuple[bytes, int]

class naz.codec.UCS2Codec[source]

Bases: codecs.Codec

This class implements the UCS2 encoding/decoding scheme. Users should never have to use this directly, instead; use naz.protocol.SubmitSM(encoding=”ucs2”)

UCS2 is for all intents & purposes assumed to be the same as big endian UTF16.

static decode(input, errors='strict')[source]

return a string decoded from the given bytes and its length.

Parameters
  • input (bytes) – the bytes to decode

  • errors (str) –

    same meaning as the errors argument to pythons’ encode method

Return type

Tuple[str, int]

static encode(input, errors='strict')[source]

return an encoded version of the string as a bytes object and its length.

Parameters
  • input (str) – the string to encode

  • errors (str) –

    same meaning as the errors argument to pythons’ encode method

Return type

Tuple[bytes, int]

naz.codec.register_codecs(custom_codecs=None)[source]

Register codecs, both custom and naz inbuilt ones. Custom codecs that have same encoding as inbuilt ones will take precedence. Users should never have to use this directly, instead; use naz.Client(custom_codecs={“my_encoding”: codecs.CodecInfo(name=”my_encoding”, encode=…, decode=…)})

Parameters

custom_codecs (Union[None, Dict[str, CodecInfo]]) – a list of custom codecs to register.