def convert_encoding(data, new_coding='UTF-8'):
    coding = icu.CharsetDetector(data).detect().getName()
if new_coding.upper() != coding.upper():
    data = str(data, coding).encode(new_coding)
return data
Python - detect charset and convert to utf-8