[plum.str] Module Reference¶
Interpret bytes as a string.
-
class
plum.str.
Str
(object, encoding='ascii', error='strict')¶ Interpret bytes as a string.
Str(object='') -> Str Str(bytes_or_buffer[, encoding[, errors]]) -> Str pack(Str, str) -> bytes unpack(Str, bytes_or_buffer) -> Str
Parameters: - object (object or bytes or buffer) – string like object
- encoding (str) – encoding name (see
codecs
standard encodings) - error (str) – (e.g.
'string'
,'ignore'
,'replace'
)
-
class
plum.str.
StrType
(name, bases, namespace, encoding=None, errors=None, nbytes=None, pad=None, zero_termination=None)¶ Str type metaclass.
Create custom
Str
subclass.Parameters: - encoding (str) – encoding name (see
codecs
standard encodings) - errors (str) – error handling (e.g.
'string'
,'ignore'
,'replace'
) - nbytes (int) – size in number of bytes
- pad (bytes) – pad value, len(pad) must equal 1
For example:
>>> from plum.str import Str >>> class MyStr(Str, encoding='ascii', nbytes=4): ... pass ... >>>
- encoding (str) – encoding name (see
-
class
plum.str.
AsciiStr
¶ Interpret bytes as ASCII encoded string.
-
class
plum.str.
AsciiZeroTermStr
¶ Interpret bytes as ASCII encoded zero terminated string.
-
class
plum.str.
Utf8Str
¶ Interpret bytes as UTF-8 encoded string.
-
class
plum.str.
Utf8ZeroTermStr
¶ Interpret bytes as UTF-8 encoded zero terminated string.