All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] shader-debugger: Force file/stdout IO as UTF-8
@ 2014-08-17 23:09 Rémi Cardona
  2014-08-27  6:37 ` Rémi Cardona
  2014-08-27  7:56 ` Damien Lespiau
  0 siblings, 2 replies; 3+ messages in thread
From: Rémi Cardona @ 2014-08-17 23:09 UTC (permalink / raw)
  To: intel-gfx

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>
---
 debugger/system_routine/pre_cpp.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/debugger/system_routine/pre_cpp.py b/debugger/system_routine/pre_cpp.py
index effea0e..584d2af 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)
-- 
2.0.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] shader-debugger: Force file/stdout IO as UTF-8
  2014-08-17 23:09 [PATCH] shader-debugger: Force file/stdout IO as UTF-8 Rémi Cardona
@ 2014-08-27  6:37 ` Rémi Cardona
  2014-08-27  7:56 ` Damien Lespiau
  1 sibling, 0 replies; 3+ messages in thread
From: Rémi Cardona @ 2014-08-27  6:37 UTC (permalink / raw)
  To: intel-gfx

Le 18/08/2014 01:09, Rémi Cardona a écrit :
> 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>

Ping ?

Rémi
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] shader-debugger: Force file/stdout IO as UTF-8
  2014-08-17 23:09 [PATCH] shader-debugger: Force file/stdout IO as UTF-8 Rémi Cardona
  2014-08-27  6:37 ` Rémi Cardona
@ 2014-08-27  7:56 ` Damien Lespiau
  1 sibling, 0 replies; 3+ messages in thread
From: Damien Lespiau @ 2014-08-27  7:56 UTC (permalink / raw)
  To: Rémi Cardona; +Cc: intel-gfx

On Mon, Aug 18, 2014 at 01:09:15AM +0200, Rémi Cardona wrote:
> 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>

Looks reasonable, pushed, thanks for the patch.

-- 
Damien

> ---
>  debugger/system_routine/pre_cpp.py | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/debugger/system_routine/pre_cpp.py b/debugger/system_routine/pre_cpp.py
> index effea0e..584d2af 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)
> -- 
> 2.0.4
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-08-27  7:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-17 23:09 [PATCH] shader-debugger: Force file/stdout IO as UTF-8 Rémi Cardona
2014-08-27  6:37 ` Rémi Cardona
2014-08-27  7:56 ` Damien Lespiau

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.