From 6eade64d807b9af1f254585eccd560eb10f68a5d Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 12 Aug 2010 10:57:47 -0600 Subject: [PATCH] Fix unicode handling when editing tweaks --- src/calibre/gui2/dialogs/config/__init__.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/calibre/gui2/dialogs/config/__init__.py b/src/calibre/gui2/dialogs/config/__init__.py index 0f66ed5dd4..3073a54774 100644 --- a/src/calibre/gui2/dialogs/config/__init__.py +++ b/src/calibre/gui2/dialogs/config/__init__.py @@ -515,15 +515,15 @@ class ConfigDialog(ResizableDialog, Ui_Dialog): self.reset_confirmation_button.clicked.connect(self.reset_confirmation) deft, curt = read_raw_tweaks() - self.current_tweaks.setPlainText(curt) - self.default_tweaks.setPlainText(deft) + self.current_tweaks.setPlainText(curt.decode('utf-8')) + self.default_tweaks.setPlainText(deft.decode('utf-8')) self.restore_tweaks_to_default_button.clicked.connect(self.restore_tweaks_to_default) self.category_view.setCurrentIndex(self.category_view.model().index_for_name(initial_category)) def restore_tweaks_to_default(self, *args): deft, curt = read_raw_tweaks() - self.current_tweaks.setPlainText(deft) + self.current_tweaks.setPlainText(deft.decode('utf-8')) def reset_confirmation(self): @@ -698,8 +698,7 @@ class ConfigDialog(ResizableDialog, Ui_Dialog): self.input_order.setCurrentRow(idx-1) def set_tweaks(self): - raw = unicode(self.current_tweaks.toPlainText()) - raw = re.sub(r'(?m)^#.*fileencoding.*', '# ', raw) + raw = unicode(self.current_tweaks.toPlainText()).encode('utf-8') try: exec raw except: