Skip to content

Instantly share code, notes, and snippets.

@mrcaron
Created May 10, 2011 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrcaron/964703 to your computer and use it in GitHub Desktop.
Save mrcaron/964703 to your computer and use it in GitHub Desktop.
Python UTF-16 to Ascii file converter
import codecs
import sys
import os
if __name__ == "__main__":
lines = ''
with codecs.open(sys.argv[1], 'r', 'utf-16') as f:
lines = f.read()
os.rename(sys.argv[1], sys.argv[1] + '_utf16')
with codecs.open(sys.argv[1], 'w', 'ascii') as w:
w.write(lines)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment