Last active
July 8, 2019 18:58
-
-
Save alpiepho/37f28a50810967020d6040c7eeb13141 to your computer and use it in GitHub Desktop.
Python - convert utf16 to utf8
This file contains hidden or 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 os, sys, codecs | |
src = ''.join(sys.argv[1:2]) | |
dest = ''.join(sys.argv[2:3]) | |
with open(src, 'rb') as source_file: | |
with open(dest, 'w+b') as dest_file: | |
contents = source_file.read() | |
dest_file.write(contents.decode('utf-16').encode('utf-8')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment