# HG changeset patch # User Björn Ricks # Date 1329134992 -3600 # Node ID 5b334ab7f1b097320472fe39b27d2c32d9cf511b # Parent 8d533c1b6d237a835f395653c650c6099a48777d Set default encoding Fixes an issue with the encoding within vim. Using e.g. :read !zeiterfassung always caused a UnicodeError without setting the encoding. diff -r 8d533c1b6d23 -r 5b334ab7f1b0 getan/contrib/zeiterfassung.py --- a/getan/contrib/zeiterfassung.py Mon Jan 16 10:13:05 2012 +0100 +++ b/getan/contrib/zeiterfassung.py Mon Feb 13 13:09:52 2012 +0100 @@ -16,6 +16,7 @@ import getopt import re import codecs +import locale from pysqlite2 import dbapi2 as db @@ -193,9 +194,10 @@ if not proj_year: proj_year = date.today().strftime("%Y") - if encoding: - Writer = codecs.getwriter(encoding) - sys.stdout = Writer(sys.stdout) + if not encoding: + encoding = locale.getdefaultlocale()[1] + Writer = codecs.getwriter(encoding) + sys.stdout = Writer(sys.stdout) if not os.path.isfile(database): print >> sys.stderr, "'%s' does not exist or is not a file." % database