From 399e64e9f4e0488e36d0ca9ee69d8f69e7e62615 Mon Sep 17 00:00:00 2001 From: Leonardo Robol Date: Sat, 11 Apr 2009 10:09:54 +0200 Subject: [PATCH] Convertita tutta la gestione in unicode per non avere problemi --- latex_manager.py | 2 ++ songbook-editor.py | 12 +++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/latex_manager.py b/latex_manager.py index 8dc85d8..089adff 100644 --- a/latex_manager.py +++ b/latex_manager.py @@ -14,6 +14,8 @@ class latex_manager(): year = song.year body = song.body + # We really have to assume that latex_song is unicode, + # or the write() function will eat us! latex_song = unicode() latex_song += "\\begin{song}{" + title + "}{" + tone + "}\n{" + mauthor + "}\n{" + tauthor + "}\n{" + year + "}" + "{}\n\n\\index{" + title + "}\n\n" diff --git a/songbook-editor.py b/songbook-editor.py index 60450e8..49f301e 100755 --- a/songbook-editor.py +++ b/songbook-editor.py @@ -21,11 +21,11 @@ class interface(QtGui.QMainWindow): print "TODO: Save data on exit" def get_active_song(self): - newtitle = str(self.ui.le_title.text()) - newmauthor = str(self.ui.le_mauthor.text()) - newtauthor = str(self.ui.le_tauthor.text()) - newyear = str(self.ui.le_year.text()) - newtone = str(self.ui.le_tone.text()) + newtitle = unicode(self.ui.le_title.text()) + newmauthor = unicode(self.ui.le_mauthor.text()) + newtauthor = unicode(self.ui.le_tauthor.text()) + newyear = unicode(self.ui.le_year.text()) + newtone = unicode(self.ui.le_tone.text()) newsong = song(newtitle, [], newmauthor, newtauthor, newtone, newyear) newbody = unicode(self.ui.te_body.toPlainText()) @@ -46,6 +46,8 @@ class interface(QtGui.QMainWindow): filetowrite = lm.create_song(song) filename = QtGui.QFileDialog.getSaveFileName(self, "Salva file latex", "/home/leonardo", "LaTeX Source File (*.tex)") handle = open(filename, 'w') + # Just remember that filetowrite is an "unicode" object, treat it + # as it just deserve handle.write(filetowrite.encode("utf-8")) handle.close() -- 2.1.4