google.protobuf.text_encoding

Encoding related utilities.

google.protobuf.text_encoding.CEscape(text, as_utf8)

Escape a bytes string for use in an text protocol buffer.

Parameters:
  • text – A byte string to be escaped.

  • as_utf8 – Specifies if result may contain non-ASCII characters. In Python 3 this allows unescaped non-ASCII Unicode characters. In Python 2 the return value will be valid UTF-8 rather than only ASCII.

Returns:

Escaped string (str).

google.protobuf.text_encoding.CUnescape(text)

Unescape a text string with C-style escape sequences to UTF-8 bytes.

Parameters:

text – The data to parse in a str.

Returns:

A byte string.