I already know if I wanna encode and decode a string in 'utf-8' , i can do ...
string = "Kröger"
print(string.encode('utf-8'))
>> b'Kr\xc3\xb6ger'
print(b'Kr\xc3\xb6ger'.decode('utf-8')
>> Kröger
If I have an string 'Kr\xc3\xb6ger' without specifying it was of <class bytes> (missing prefix 'b'), how will I decode this ?
Edit:
I have a tokenized list if it helps : ['K', 'r', '\\xc3\\xb6', 'g', 'e', 'r']
'Kr\xc3\xb6ger'or'Kr\\xc3\\xb6ger'? What's the length of the string?'Kr\xc3\xb6ger',len(striing) = 7'Kr\xc3\xb6ger'.encode('latin1').decode('utf8')encoding='utf8'whenopening a file for reading).