402-charset-normalizer

1
2
3
4
from charset_normalizer import from_bytes
raw_data = b'\xe4\xb8\xad\xe6\x96\x87'  # UTF-8 编码的“中文”
result = from_bytes(raw_data).best()
print(result.encoding)  # utf-8