This document describes the current stable version of Kombu (5.3). For development docs, go here.

String Encoding Utilities - kombu.utils.encoding

Text encoding utilities.

Utilities to encode text, and to safely emit text from running applications without crashing from the infamous UnicodeDecodeError exception.

kombu.utils.encoding.bytes_to_str(s)[source]

Convert bytes to str.

kombu.utils.encoding.default_encode(obj)[source]

Encode using default encoding.

kombu.utils.encoding.default_encoding(file=None)[source]

Get default encoding.

kombu.utils.encoding.default_encoding_file = None

safe_str takes encoding from this file by default. set_default_encoding_file() can used to set the default output file.

kombu.utils.encoding.ensure_bytes(s)[source]

Ensure s is bytes, not str.

kombu.utils.encoding.from_utf8(s, *args, **kwargs)[source]

Get str from utf-8 encoding.

kombu.utils.encoding.get_default_encoding_file()[source]

Get file used to get codec information.

kombu.utils.encoding.safe_repr(o, errors='replace')[source]

Safe form of repr, void of Unicode errors.

kombu.utils.encoding.safe_str(s, errors='replace')[source]

Safe form of str(), void of unicode errors.

kombu.utils.encoding.set_default_encoding_file(file)[source]

Set file used to get codec information.

kombu.utils.encoding.str_to_bytes(s)[source]

Convert str to bytes.