def parse_unicode_str(string): try: return string.decode('utf8') except (UnicodeEncodeError, UnicodeDecodeError): return string