I know that bytes.decode gives a string and string.encode gives the bytes, but only if the correct encoding is used.
Suppose I have a bytes object encoded using gb18030
If I try to decode it using big5:
>>name = '深入 damon'
>>b1 = name.encode('gb18030')
>>> b1.decode('big5')
UnicodeDecodeError: 'big5' codec can't decode byte 0xc8 in position 2: illegal multibyte sequence
Is there some way the encoding can be found from a bytes object?
I couldn't find any useful api in this regard in python3docs.
 
     
     
     
    