API Reference

genutils.strings

Convert between string and bytes.

Some functions helping with string encoding and decoding.

genutils.strings.to_bytes(str_or_bytes, encoding='utf-8)')[source]

Take argument and return as bytes.

Parameters:
  • str_or_bytes (str or bytes) – argument to encode.
  • encoding – the encoding to use if argument is of type str
Returns:

argument as bytes

Return type:

bytes

genutils.strings.to_str(str_or_bytes, encoding='utf-8')[source]

Take argument and return as unicode string.

Parameters:
  • str_or_bytes (str or bytes) – argument to decode.
  • encoding – the encoding to use if argument is of type bytes
Returns:

argument as unicode string.

Return type:

str