[aisleriot] guile: Set the default port encoding to UTF-8



commit 3383b6786e9631daab378628a01d6750f11677fe
Author: Christian Persch <chpe gnome org>
Date:   Sat Mar 5 20:29:34 2016 +0100

    guile: Set the default port encoding to UTF-8
    
    This is the encoding that strings returned from 'format' are in,
    so since we need all strings to be UTF-8 independently of the locale
    encoding, we need to set this explicitly to UTF-8.
    (Also guile docs say this is picked up from the locale encoding,
    but even though we call setlocale(3), the default port encoding
    isn't set, for whatever reason.)
    
    https://bugzilla.gnome.org/show_bug.cgi?id=733881

 games/api.scm |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/games/api.scm b/games/api.scm
index c50b723..7ecf75d 100644
--- a/games/api.scm
+++ b/games/api.scm
@@ -18,6 +18,16 @@
 
 (use-modules (aisleriot interface) (ice-9 format) (ice-9 i18n))
 
+;; This is the encoding of strings returned from e.g. 'format',
+;; so we need to set this to "UTF-8" since that's what the C side
+;; of aisleriot expects.  Otherwise as per docs, guile sets this
+;; from the locale encoding, which would be wrong if the locale is
+;; an not UTF-8 locale, and also it seems that even though we call
+;; setlocale(3), the guile side does not pick this up, for whatever
+;; reason.
+;; Bug #733881.
+(fluid-set! %default-port-encoding "UTF-8")
+
 ;; Define the usual alias for gettext
 (define-public (_ msg) (gettext msg "aisleriot"))
 


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