Skip to content

Instantly share code, notes, and snippets.

@inky
Created July 11, 2010 13:01
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save inky/471524 to your computer and use it in GitHub Desktop.
Save inky/471524 to your computer and use it in GitHub Desktop.
Convert a file from UTF-8 to CP437.
#!/usr/bin/env python
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').write(nfo)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment