import chardet
import codecs

input_file = './some.h'
output_file = './some.h.new'

with open(input_file, 'rb') as f:
    data = f.read()
    encoding_type = chardet.detect(data)
    print(encoding_type["encoding"])

with codecs.open(filename=input_file, mode='r', encoding='gb2312') as fi:
    data = fi.read()
    with open(output_file, mode='w', encoding='utf-8') as fo:
        fo.write(data)
        fo.close()