def unquote_utf8(qs): if isinstance(qs, text_type): qs = qs.encode('utf-8') s = unquote(qs) if isinstance(s, byte_type): return s.decode("utf-8") else: return s