From d152dd2990cfcd7a33cdf9415bcc4f3f6bea0044 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20=C3=96zkural?= Date: Tue, 4 Oct 2005 23:41:50 +0000 Subject: [PATCH] * let's try a workaround for choosing a smart output encoding --- pisi/cli/__init__.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pisi/cli/__init__.py b/pisi/cli/__init__.py index b5a78e74..838feba2 100644 --- a/pisi/cli/__init__.py +++ b/pisi/cli/__init__.py @@ -39,16 +39,22 @@ class CLI(UI): def __init__(self, show_debug = False, show_verbose = False): super(CLI, self).__init__(show_debug, show_verbose) - #self.encoding = locale.getpreferredencoding() - #self.encoding = self.encoding.lower() - #FIXME: above code does not work for some reason on MDK! + locale.setlocale(locale.LC_ALL, '') + #print locale.getlocale() + 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): if err: out = sys.stdout else: out = sys.stderr - out.write(str.encode('utf-8')) + out.write(str.encode(self.encoding)) out.flush() def info(self, msg, verbose = False, noln = False):