Skip to content

Instantly share code, notes, and snippets.

@christiansacks
Forked from inky/convert_nfo.py
Last active March 25, 2022 01:09
Show Gist options
  • Save christiansacks/ebead3004aac0b24fb4a763e0f19eec6 to your computer and use it in GitHub Desktop.
Save christiansacks/ebead3004aac0b24fb4a763e0f19eec6 to your computer and use it in GitHub Desktop.
Convert a file from UTF-8 to CP437.
#!/usr/bin/env python3
import codecs, sys
try:
infile, outfile = sys.argv[1], sys.argv[2]
except IndexError:
sys.stderr.write('usage: %s input_file output_file\n' % sys.argv[0])
sys.exit(1)
nfo = codecs.open(infile, encoding='utf-8').read()
codecs.open(outfile, 'w', encoding='cp437', errors='replace').write(nfo)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment