Package google :: Package protobuf :: Module text_encoding
[hide private]
[frames] | no frames]

Module text_encoding

source code

Encoding related utilities.

Functions [hide private]
 
CEscape(text, as_utf8)
Escape a bytes string for use in an text protocol buffer.
source code
 
CUnescape(text)
Unescape a text string with C-style escape sequences to UTF-8 bytes.
source code
Variables [hide private]
  _cescape_chr_to_symbol_map = {9: '\\t', 10: '\\n', 13: '\\r', ...
  _cescape_unicode_to_str = ['\x00', '\x01', '\x02', '\x03', '\x...
  _cescape_byte_to_str = ['\\000', '\\001', '\\002', '\\003', '\...
  _CUNESCAPE_HEX = re.compile(r'(\\+)x([0-9a-fA-F])(?![0-9a-fA-F...
  __package__ = 'google.protobuf'
  i = 255
Function Details [hide private]

CEscape(text, as_utf8)

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

Args:
  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).

CUnescape(text)

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

Args:
  text: The data to parse in a str.
Returns:
  A byte string.


Variables Details [hide private]

_cescape_chr_to_symbol_map

Value:
{9: '\\t', 10: '\\n', 13: '\\r', 34: '\\"', 39: '\\\'', 92: '\\\\'}

_cescape_unicode_to_str

Value:
['\x00',
 '\x01',
 '\x02',
 '\x03',
 '\x04',
 '\x05',
 '\x06',
 '\x07',
...

_cescape_byte_to_str

Value:
['\\000',
 '\\001',
 '\\002',
 '\\003',
 '\\004',
 '\\005',
 '\\006',
 '\\007',
...

_CUNESCAPE_HEX

Value:
re.compile(r'(\\+)x([0-9a-fA-F])(?![0-9a-fA-F])')