]> git.sommitrealweird.co.uk Git - curses-crossword.git/blobdiff - curses-crossword.py
Actually encode to the terminals locale, if we can.
[curses-crossword.git] / curses-crossword.py
index 92f9b926394fa9ee8df623d348cd0715c4c2ff10..6d8791a64cfeda7e96a2fcfc145c74270431c898 100644 (file)
@@ -32,7 +32,11 @@ except:
 
 filename = None
 
-(options, args) = getopt.getopt(sys.argv[1:], "f:", "file=")
+try:
+    (options, args) = getopt.getopt(sys.argv[1:], "f:", "file=")
+except getopt.GetoptError, err:
+    print str(err)
+    sys.exit(2)
 
 for option in options:
     if option[0] == "-f" or option[0] == "--file":
@@ -80,13 +84,13 @@ def parsecrossword(crossworddata):
                     parts = line.split()
                     question_number = int(parts[0])
                     clue = " ".join(parts[1:])
-                    crossword["across"][int(question_number)] = clue.encode('utf-8')
+                    crossword["across"][int(question_number)] = clue.encode(code)
             if indown:
                 if line != "":
                     parts = line.split()
                     question_number = int(parts[0])
                     clue = " ".join(parts[1:])
-                    crossword["down"][int(question_number)] = clue.encode('utf-8')
+                    crossword["down"][int(question_number)] = clue.encode(code)
     num_cols = len(crossword["grid"][0])
     num_rows = len(crossword["grid"])