Skip to content

Instantly share code, notes, and snippets.

@haradreborn
Last active August 29, 2015 14:08
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 haradreborn/cece1b3474dfb11be498 to your computer and use it in GitHub Desktop.
Save haradreborn/cece1b3474dfb11be498 to your computer and use it in GitHub Desktop.
Change file encoding
import codecs
def change_code(self, file_from, file_to):
BLOCKSIZE = 1048576 # or some other, desired size in bytes
with codecs.open(file_from, "r", "utf-16") as sourceFile:
with codecs.open(file_to, "w", "utf-8") as targetFile:
while True:
contents = sourceFile.read(BLOCKSIZE)
if not contents:
break
targetFile.write(contents)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment