There are many questions about utf-8 > unicode conversion, but I still haven't found answer for my issue.
Lets have strings like this:
a = "Je-li pro za\\xc5\\x99azov\\xc3\\xa1n\\xc3\\xad"
Python 3.6 understands this string like Je-li pro za\xc5\x99azov\xc3\xa1n\xc3\xad. I need to convert this utf-8-like string to unicode representation. The final result should be Je-li pro zařazování.
With a.decode("utf-8")
I get AttributeError: 'str' object has no attribute 'decode', because Python means the object is already decoded.
If I convert it to bytes first with bytes(a, "utf-8")
, the backslashes are doubled only and .decode("utf-8")
returns it to my current a
again.
How to get unicode string Je-li pro zařazování from this a
?