Skip to content

Instantly share code, notes, and snippets.

@starenka
Created December 6, 2011 11:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save starenka/1437922 to your computer and use it in GitHub Desktop.
Save starenka/1437922 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import codecs, sys
from optparse import OptionParser
usage = "\n\t$FILE [-i]"
parser = OptionParser(usage)
parser.add_option('-i','--input',action='store',dest='input',default = False, help='input file')
(options,args) = parser.parse_args()
if options.input:
with codecs.open(options.input,'r','utf8') as f:
content = f.read()
with codecs.open(options.input,'w','utf8') as f:
f.write(content.decode('unicode_escape'))
else:
sys.exit('No input file specified. See $FILE -h')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment