def pprint_thing(thing, _nest_lvl=<NUM_LIT:0>, escape_chars=None, default_escapes=False,<EOL>quote_strings=False, max_seq_items=None):
def as_escaped_unicode(thing, escape_chars=escape_chars):<EOL><INDENT>try:<EOL><INDENT>result = str(thing)  <EOL><DEDENT>except UnicodeDecodeError:<EOL><INDENT>result = str(thing).decode('<STR_LIT:utf-8>', "<STR_LIT:replace>")<EOL><DEDENT>translate = {'<STR_LIT:\t>': r'<STR_LIT:\t>', '<STR_LIT:\n>': r'<STR_LIT:\n>', '<STR_LIT:\r>': r'<STR_LIT:\r>', }<EOL>if isinstance(escape_chars, dict):<EOL><INDENT>if default_escapes:<EOL><INDENT>translate.update(escape_chars)<EOL><DEDENT>else:<EOL><INDENT>translate = escape_chars<EOL><DEDENT>escape_chars = list(escape_chars.keys())<EOL><DEDENT>else:<EOL><INDENT>escape_chars = escape_chars or tuple()<EOL><DEDENT>for c in escape_chars:<EOL><INDENT>result = result.replace(c, translate[c])<EOL><DEDENT>return str(result)<EOL><DEDENT>if hasattr(thing, '<STR_LIT>'):<EOL><INDENT>return str(thing)<EOL><DEDENT>elif (isinstance(thing, dict) and<EOL>_nest_lvl < get_option("<STR_LIT>")):<EOL><INDENT>result = _pprint_dict(thing, _nest_lvl, quote_strings=True,<EOL>max_seq_items=max_seq_items)<EOL><DEDENT>elif (is_sequence(thing) and<EOL>_nest_lvl < get_option("<STR_LIT>")):<EOL><INDENT>result = _pprint_seq(thing, _nest_lvl, escape_chars=escape_chars,<EOL>quote_strings=quote_strings,<EOL>max_seq_items=max_seq_items)<EOL><DEDENT>elif isinstance(thing, str) and quote_strings:<EOL><INDENT>result = "<STR_LIT>".format(thing=as_escaped_unicode(thing))<EOL><DEDENT>else:<EOL><INDENT>result = as_escaped_unicode(thing)<EOL><DEDENT>return str(result)<EOL>
This function is the sanctioned way of converting objects
to a unicode representation.

properly handles nested sequences containing unicode strings
(unicode(object) does not)

Parameters
----------
thing : anything to be formatted
_nest_lvl : internal use only. pprint_thing() is mutually-recursive
    with pprint_sequence, this argument is used to keep track of the
    current nesting level, and limit it.
escape_chars : list or dict, optional
    Characters to escape. If a dict is passed the values are the
    replacements
default_escapes : bool, default False
    Whether the input escape characters replaces or adds to the defaults
max_seq_items : False, int, default None
    Pass thru to other pretty printers to limit sequence printing

Returns
-------
result - unicode str