setup utf8 output encoding

This commit is contained in:
Elan Ruusamäe 2012-09-22 20:23:43 +02:00
parent 8411723b65
commit de270d83ee

View file

@ -227,6 +227,15 @@ def convertfile(pagedir, output = None, overwrite = False):
# #
# "main" starts here # "main" starts here
# #
# setup utf8 output
if sys.stdout.isatty():
default_encoding = sys.stdout.encoding
else:
import locale
default_encoding = locale.getpreferredencoding()
sys.stdout = codecs.getwriter(default_encoding)(sys.stdout);
try: try:
opts, args = getopt.getopt(sys.argv[1:], 'hfad:F:r:', [ "help" ]) opts, args = getopt.getopt(sys.argv[1:], 'hfad:F:r:', [ "help" ])
except getopt.GetoptError, e: except getopt.GetoptError, e: