From 577a72baf50730fb7d8f91eec8ba28a5923c0908 Mon Sep 17 00:00:00 2001 From: Salvatore Larosa Date: Sat, 10 Aug 2013 00:55:41 +0200 Subject: [PATCH] [pyqgis-console] more encoding fix. --- python/console/console_editor.py | 2 +- python/console/console_sci.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/python/console/console_editor.py b/python/console/console_editor.py index 8f47ac10bf7..485e3e72d3b 100644 --- a/python/console/console_editor.py +++ b/python/console/console_editor.py @@ -576,7 +576,7 @@ class Editor(QsciScintilla): tmpFile = self.createTempFile() filename = tmpFile - self.parent.pc.shell.runCommand("execfile(r'{0}')".format(filename)) + self.parent.pc.shell.runCommand(u"execfile(r'{0}')".format(filename)) def runSelectedCode(self): cmd = self.selectedText() diff --git a/python/console/console_sci.py b/python/console/console_sci.py index 223890db091..7b2a4417deb 100644 --- a/python/console/console_sci.py +++ b/python/console/console_sci.py @@ -29,6 +29,7 @@ from PyQt4.Qsci import (QsciScintilla, import sys import os import code +import codecs from qgis.core import QgsApplication from ui_console_history_dlg import Ui_HistoryDialogPythonConsole @@ -277,7 +278,7 @@ class ShellScintilla(QsciScintilla, code.InteractiveInterpreter): def writeHistoryFile(self, fromCloseConsole=False): ok = False try: - wH = open(_historyFile, 'w') + wH = codecs.open(_historyFile, 'w', encoding='utf-8') for s in self.history: wH.write(s + '\n') ok = True @@ -292,7 +293,7 @@ class ShellScintilla(QsciScintilla, code.InteractiveInterpreter): def readHistoryFile(self): fileExist = QFile.exists(_historyFile) if fileExist: - rH = open(_historyFile, 'r') + rH = codecs.open(_historyFile, 'r', encoding='utf-8') for line in rH: if line != "\n": l = line.rstrip('\n') @@ -309,7 +310,7 @@ class ShellScintilla(QsciScintilla, code.InteractiveInterpreter): return ok = False try: - cH = open(_historyFile, 'w') + cH = codecs.open(_historyFile, 'w', encoding='utf-8') ok = True except: raise