diff options
author | Rémi Cardona <remi@gentoo.org> | 2014-08-18 01:09:15 +0200 |
---|---|---|
committer | Damien Lespiau <damien.lespiau@intel.com> | 2014-08-27 08:56:08 +0100 |
commit | 2ef19ad79a07d862a2dc799ab2e71d2ad91c9065 (patch) | |
tree | c2fe8c0d2cc637133d5ad466d31db9c82dda22b8 | |
parent | 257a51ec955b178ed07e4797a7d36f35a8cc82fe (diff) |
shader-debugger: Force file/stdout IO as UTF-8
Not all locales on linux are UTF-8, the most notable being the C locale.
Python will use the ASCII codec for stream IO in this case and will barf
on the Copyright sign at the top of .g4a files.
Bugzilla: https://bugs.gentoo.org/show_bug.cgi?id=519434
Signed-off-by: Rémi Cardona <remi@gentoo.org>
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
-rwxr-xr-x | debugger/system_routine/pre_cpp.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/debugger/system_routine/pre_cpp.py b/debugger/system_routine/pre_cpp.py index effea0e2..584d2af0 100755 --- a/debugger/system_routine/pre_cpp.py +++ b/debugger/system_routine/pre_cpp.py @@ -33,7 +33,10 @@ import sys,re -file = open(sys.argv[1], "r") +# make sure both input file and stdout are handled as utf-8 text, regardless +# of current locale (eg. LANG=C which tells python to use ascii encoding) +sys.stdout = open(sys.__stdout__.fileno(), "a", encoding="utf-8") +file = open(sys.argv[1], "r", encoding="utf-8") lines = file.readlines() len(lines) |