encodeutils

oslo_utils.encodeutils.safe_decode(text, incoming=None, errors='strict')
Decodes incoming text/bytes string using incoming if they’re not
already unicode.
Parameters:
Returns:

text or a unicode incoming encoded representation of it.

Raises TypeError:
 

If text is not an instance of str

oslo_utils.encodeutils.safe_encode(text, incoming=None, encoding='utf-8', errors='strict')

Encodes incoming text/bytes string using encoding.

If incoming is not specified, text is expected to be encoded with current python’s default encoding. (sys.getdefaultencoding)

Parameters:
Returns:

text or a bytestring encoding encoded representation of it.

Raises TypeError:
 

If text is not an instance of str

Previous topic

API

Next topic

eventletutils

This Page