def to_native_string(string, encoding='<STR_LIT:ascii>'):
out = None<EOL>if isinstance(string, builtin_str):<EOL><INDENT>out = string<EOL><DEDENT>else:<EOL><INDENT>if is_py2:<EOL><INDENT>out = string.encode(encoding)<EOL><DEDENT>else:<EOL><INDENT>out = string.decode(encoding)<EOL><DEDENT><DEDENT>return out<EOL>
Given a string object, regardless of type, returns a representation of that
string in the native string type, encoding and decoding where necessary.
This assumes ASCII unless told otherwise.