* let's try a workaround for choosing a smart output encoding
This commit is contained in:
+10
-4
@@ -39,16 +39,22 @@ class CLI(UI):
|
|||||||
|
|
||||||
def __init__(self, show_debug = False, show_verbose = False):
|
def __init__(self, show_debug = False, show_verbose = False):
|
||||||
super(CLI, self).__init__(show_debug, show_verbose)
|
super(CLI, self).__init__(show_debug, show_verbose)
|
||||||
#self.encoding = locale.getpreferredencoding()
|
locale.setlocale(locale.LC_ALL, '')
|
||||||
#self.encoding = self.encoding.lower()
|
#print locale.getlocale()
|
||||||
#FIXME: above code does not work for some reason on MDK!
|
self.encoding = locale.getpreferredencoding()
|
||||||
|
locale.setlocale(locale.LC_ALL, 'C')
|
||||||
|
# workaround a silly python bug!
|
||||||
|
self.encoding = self.encoding.lower()
|
||||||
|
locale.setlocale(locale.LC_ALL, '')
|
||||||
|
if show_debug:
|
||||||
|
print 'output encoding: ', self.encoding
|
||||||
|
|
||||||
def output(self, str, err = False):
|
def output(self, str, err = False):
|
||||||
if err:
|
if err:
|
||||||
out = sys.stdout
|
out = sys.stdout
|
||||||
else:
|
else:
|
||||||
out = sys.stderr
|
out = sys.stderr
|
||||||
out.write(str.encode('utf-8'))
|
out.write(str.encode(self.encoding))
|
||||||
out.flush()
|
out.flush()
|
||||||
|
|
||||||
def info(self, msg, verbose = False, noln = False):
|
def info(self, msg, verbose = False, noln = False):
|
||||||
|
|||||||
Reference in New Issue
Block a user