[gedit/wip/bug-722948] Open files with utf-8 encoding



commit 23d8ab160a27ed00aa80ffc82a724dc3ba8e250b
Author: Jesse van den Kieboom <jessevdk gmail com>
Date:   Sat Apr 12 17:04:28 2014 +0200

    Open files with utf-8 encoding
    
    This fixes issues in python 3 for reading tools and snippets
    files when gedit is run in an environment with a non utf-8
    locale

 plugins/externaltools/tools/library.py |    8 ++++----
 plugins/snippets/snippets/library.py   |    2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/plugins/externaltools/tools/library.py b/plugins/externaltools/tools/library.py
index 478b617..adfd943 100644
--- a/plugins/externaltools/tools/library.py
+++ b/plugins/externaltools/tools/library.py
@@ -246,7 +246,7 @@ class Tool(object):
         if filename is None:
             return
 
-        fp = open(filename, 'r', 1)
+        fp = open(filename, 'r', 1, encoding='utf-8')
         in_block = False
         lang = locale.getlocale(locale.LC_MESSAGES)[0]
 
@@ -395,7 +395,7 @@ class Tool(object):
         if filename is None:
             return True
 
-        fp = open(filename, 'r', 1)
+        fp = open(filename, 'r', 1, encoding='utf-8')
         for line in fp:
             if line.strip() == '':
                 continue
@@ -411,7 +411,7 @@ class Tool(object):
         if filename is None:
             return ["#!/bin/sh\n"]
 
-        fp = open(filename, 'r', 1)
+        fp = open(filename, 'r', 1, encoding='utf-8')
         lines = list()
 
         # before entering the data block
@@ -445,7 +445,7 @@ class Tool(object):
 
     def save_with_script(self, script):
         filename = self.library.get_full_path(self.filename, 'w')
-        fp = open(filename, 'w', 1)
+        fp = open(filename, 'w', 1, encoding='utf-8')
 
         # Make sure to first print header (shebang, modeline), then
         # properties, and then actual content
diff --git a/plugins/snippets/snippets/library.py b/plugins/snippets/snippets/library.py
index c60695f..a357876 100644
--- a/plugins/snippets/snippets/library.py
+++ b/plugins/snippets/snippets/library.py
@@ -457,7 +457,7 @@ class SnippetsSystemFile:
                 self.insnippet = False
 
                 try:
-                        f = open(self.path, "r")
+                        f = open(self.path, "r", encoding='utf-8')
                 except IOError:
                         self.ok = False
                         return


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]