Skip to content
Permalink
Browse files
[pyqgis-console] encoding to utf-8 when open or save a script file: a…
…gain fixes for non-ascii chars
  • Loading branch information
slarosa committed Aug 7, 2013
1 parent 39f2898 commit d821bcc31bdf00a768ffafaa418e59c474ba5752
Showing with 5 additions and 4 deletions.
  1. +5 −4 python/console/console_editor.py
@@ -35,6 +35,7 @@
import pyclbr
from operator import itemgetter
import traceback
import codecs

class KeyFilter(QObject):
SHORTCUTS = {
@@ -486,7 +487,7 @@ def createTempFile(self):
import tempfile
fd, path = tempfile.mkstemp()
tmpFileName = path + '.py'
with open(path, "w") as f:
with codecs.open(path, "w", encoding='utf-8') as f:
f.write(self.text())
os.close(fd)
os.rename(path, tmpFileName)
@@ -758,7 +759,7 @@ def __init__(self, parent, parentConsole, filename, readOnly):

def loadFile(self, filename, modified):
self.newEditor.lastModified = QFileInfo(filename).lastModified()
fn = open(unicode(filename), "rb")
fn = codecs.open(unicode(filename), "rb", encoding='utf-8')
txt = fn.read()
fn.close()
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
@@ -804,7 +805,7 @@ def save(self, fileName=None):
os.remove(temp_path)
os.rename(path, temp_path)
# Save the new contents
with open(path, "w") as f:
with codecs.open(path, "w", encoding='utf-8') as f:
f.write(self.newEditor.text())
if overwrite:
os.remove(temp_path)
@@ -1007,7 +1008,7 @@ def newTabEditor(self, tabName=None, filename=None):
if filename:
readOnly = not QFileInfo(filename).isWritable()
try:
fn = open(unicode(filename), "rb")
fn = codecs.open(unicode(filename), "rb", encoding='utf-8')
txt = fn.read()
fn.close()
except IOError, error:

0 comments on commit d821bcc

Please sign in to comment.