Weyaxi's picture
Duplicate from Weyaxi/commit-trash-huggingface-spaces-codes
42472b3
raw
history blame
207 Bytes
import chardet
def get_encoding(file):
with open(file, 'rb') as f:
encoding = chardet.detect(f.read())['encoding']
if encoding == 'GB2312':
encoding = 'GB18030'
return encoding