Skip to content

Instantly share code, notes, and snippets.

@mrsarm
Last active August 22, 2019 19:54
Show Gist options
  • Save mrsarm/b576353cd2a217da6cc23706c1153b1d to your computer and use it in GitHub Desktop.
Save mrsarm/b576353cd2a217da6cc23706c1153b1d to your computer and use it in GitHub Desktop.
Use: ./msdos2utf8.py OLD_DOS_FILE NEW_ENCODED_FILE
#!/usr/bin/python3
#
# Usage: ./msdos2utf8.py OLD_DOS_FILE NEW_ENCODED_FILE
#
# Creates a new file UTF-8 encoded, taking the input file as a file with old ASCII encoded used in MS-DOS systems.
#
# Try to replace 'cp437' with 'iso8859' if the new file isn't encoded properly
import sys
with open(sys.argv[1], encoding='cp437') as infile:
with open(sys.argv[2], 'w', encoding='utf8') as outfile:
outfile.write(infile.read())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment