Skip to content

Instantly share code, notes, and snippets.

@filipposc5
Last active July 1, 2016 17:39
Show Gist options
  • Select an option

  • Save filipposc5/d9b670c41452d36a42a372a507971f63 to your computer and use it in GitHub Desktop.

Select an option

Save filipposc5/d9b670c41452d36a42a372a507971f63 to your computer and use it in GitHub Desktop.
utf-16le ?
import codecs
aaa = [ "aa", "bb", "cc", ]
with codecs.open("old.txt", mode='w', encoding='utf-16le') as f:
f.write("\n".join(aaa) + "\n")
file_old = codecs.open('old.txt', mode='r', encoding='utf-16-le')
file_new = codecs.open('new.txt', mode='w', encoding='utf-16')
text = file_old.read().split("\\n")
print text
#bom = codecs.BOM_UTF16_LE
#file_new.write('\ufeff')
file_new.write("\r\n".join(text))
file_new.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment