def decode_string(v, encoding="<STR_LIT:utf-8>"):
if isinstance(encoding, basestring):<EOL><INDENT>encoding = ((encoding,),) + (("<STR_LIT>",), ("<STR_LIT:utf-8>", "<STR_LIT:ignore>"))<EOL><DEDENT>if isinstance(v, binary_type):<EOL><INDENT>for e in encoding:<EOL><INDENT>try:<EOL><INDENT>return v.decode(*e)<EOL><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>return v<EOL><DEDENT>return unicode(v)<EOL>
Returns the given value as a Unicode string (if possible).