Last active
August 29, 2015 14:08
-
-
Save haradreborn/cece1b3474dfb11be498 to your computer and use it in GitHub Desktop.
Change file encoding
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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