esptest.common.encoding module

esptest.common.encoding.to_str(data, encoding='utf-8', errors='replace')[source]

Turn bytes or str to str

Parameters:
  • data (AnyStr) – input bytes or str data

  • encoding (str, optional) – The encoding with which to decode the bytes. Defaults to ‘utf-8’.

  • errors (str, optional) – The error handling scheme to use for the handling of decoding errors.

Returns:

utf8-decoded string

Return type:

str

esptest.common.encoding.to_bytes(data, ending=None, encoding='utf-8')[source]

Turn bytes or str to bytes

Parameters:
  • data (AnyStr) – input bytes or str data

  • ending (Optional[AnyStr], optional) – add encoded given ending to the end of data. Defaults to None.

  • encoding (str, optional) – The encoding with which to encode the string. Defaults to ‘utf-8’.

Returns:

utf8-encoded bytes

Return type:

bytes