[gtk+] Enforce UTF-8 encoding when opening C files



commit f83b3c8af2e0b02aa7e67fdbba6d5cae12658652
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Thu Jan 18 19:23:16 2018 +0000

    Enforce UTF-8 encoding when opening C files
    
    We have a couple of Python 3.x scripts that parse C files, and since C
    does not have any encoding, we need to force one ourselves, to avoid the
    case when we're running the build in a non-UTF-8 locale.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=792497

 demos/gtk-demo/geninclude.py    |    2 +-
 gdk/wayland/genprotocolfiles.py |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/demos/gtk-demo/geninclude.py b/demos/gtk-demo/geninclude.py
index 57038a4..cd0af14 100755
--- a/demos/gtk-demo/geninclude.py
+++ b/demos/gtk-demo/geninclude.py
@@ -33,7 +33,7 @@ demos = []
 for demo_file in in_files:
     filename =  demo_file[demo_file.rfind('/')+1:]
     demo_name = filename.replace(".c", "")
-    with open(demo_file, 'r') as f:
+    with open(demo_file, 'r', encoding='utf-8') as f:
         title = f.readline().replace("/*", "").strip()
 
 
diff --git a/gdk/wayland/genprotocolfiles.py b/gdk/wayland/genprotocolfiles.py
index cf4faed..1edd4e3 100755
--- a/gdk/wayland/genprotocolfiles.py
+++ b/gdk/wayland/genprotocolfiles.py
@@ -19,7 +19,7 @@ if pc.returncode != 0:
 
 # Now read the generated file again and remove all WL_EXPORTs
 content = ""
-with open(out_file, 'r') as content_file:
+with open(out_file, 'r', encoding='utf-8') as content_file:
     content = content_file.read()
 
 content = content.replace('WL_EXPORT ', '')


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