How can I add BOM (unicode signature) while saving file in python:
file_old = open('old.txt', mode='r', encoding='utf-8')
file_new = open('new.txt', mode='w', encoding='utf-16-le')
file_new.write(file_old.read())
I need to convert file to utf-16-le + BOM
. Now script is working great, except that there is no BOM.
for line in file_old: file_new.write(line)
is vastly more memory efficient. And why can't you use any of the numerous software that already does this?