From 33d9b19ac7c12a09c5c9e2c5635d01c84340cf46 Mon Sep 17 00:00:00 2001 From: John Ralls Date: Mon, 11 Mar 2013 22:44:29 +0000 Subject: [PATCH] GrampsLocale: Ensure that encoding gets set to something In the C locale, locale.getlocale() returns [None, None] svn: r21616 --- gramps/gen/utils/grampslocale.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gramps/gen/utils/grampslocale.py b/gramps/gen/utils/grampslocale.py index a4df7cb73..82a47b403 100644 --- a/gramps/gen/utils/grampslocale.py +++ b/gramps/gen/utils/grampslocale.py @@ -223,6 +223,11 @@ class GrampsLocale(object): pass #Next, we need to know what is the encoding from the native environment: self.encoding = locale.getlocale()[1] + if not self.encoding: + self.encoding = locale.getpreferredencoding() + if not self.encoding: + self.encoding = 'utf-8' + #GtkBuilder depends on reading Glade files as UTF-8 and crashes if it #doesn't, so set $LANG to have a UTF-8 locale. NB: This does *not* #affect locale.getpreferredencoding() or sys.getfilesystemencoding()