]> khamidou — GitHub mirrors - liszt.git/commitdiff
fixed weird unicode piping bug
authorkhamidou <khamidou@gmail.com>
Fri, 12 Feb 2010 08:13:40 +0000 (09:13 +0100)
committerkhamidou <khamidou@gmail.com>
Fri, 12 Feb 2010 08:13:40 +0000 (09:13 +0100)
liszt

diff --git a/liszt b/liszt
index b7d1212182b7fb7f85371462a3d6ade347f493bd..a609d5e7f757f9a40ed0b38bb0d86a6460a7d6fd 100755 (executable)
--- a/liszt
+++ b/liszt
@@ -1,4 +1,5 @@
 #!/usr/bin/env python
+#coding=utf8
 from __future__ import with_statement
 # 
 
@@ -14,13 +15,14 @@ import fnmatch
 import tempfile
 import datetime
 import locale
+import codecs
 
 try:
     import json 
 except ImportError:
     import simplejson as json                                                                                                                         
 
-locale.setlocale(locale.LC_ALL, locale=locale.getdefaultlocale())
+sys.stdout = codecs.getwriter(locale.getpreferredencoding())(sys.stdout)
 
 def help():
     print "liszt c|create listname ?entryname? "
@@ -164,7 +166,7 @@ class CommandParser(object):
             except IndexError:
                 bailout("Invalid entry index.")
 
-            print entry["title"].decode("utf8") + "\t" + entry["date"]
+            print entry["title"] + "\t" + entry["date"]
 
     def parse_remove(self, args):
         if len(args) == 0 or len(args) > 2: