@sanitize<EOL>def ported_string(raw_data, encoding='<STR_LIT:utf-8>', errors='<STR_LIT:ignore>'):
if not raw_data:<EOL><INDENT>return six.text_type()<EOL><DEDENT>if isinstance(raw_data, six.text_type):<EOL><INDENT>return raw_data.strip()<EOL><DEDENT>if six.PY2:<EOL><INDENT>try:<EOL><INDENT>return six.text_type(raw_data, encoding, errors).strip()<EOL><DEDENT>except LookupError:<EOL><INDENT>return six.text_type(raw_data, "<STR_LIT:utf-8>", errors).strip()<EOL><DEDENT><DEDENT>if six.PY3:<EOL><INDENT>try:<EOL><INDENT>return six.text_type(raw_data, encoding).strip()<EOL><DEDENT>except (LookupError, UnicodeDecodeError):<EOL><INDENT>return six.text_type(raw_data, "<STR_LIT:utf-8>", errors).strip()<EOL><DEDENT><DEDENT>
Give as input raw data and output a str in Python 3
and unicode in Python 2.

Args:
    raw_data: Python 2 str, Python 3 bytes or str to porting
    encoding: string giving the name of an encoding
    errors: his specifies the treatment of characters
        which are invalid in the input encoding

Returns:
    str (Python 3) or unicode (Python 2)