def convert_encoding(data, new_coding='UTF-8'):
    encoding = cchardet.detect(data)['encoding']
if new_coding.upper() != encoding.upper():
    data = data.decode(encoding, data).encode(new_coding)
return data
Python - detect charset and convert to utf-8