From 474e2ff2c8901e5ef5b376d3206d95dbaab62625 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Tue, 5 Dec 2006 20:42:32 +0000 Subject: [PATCH] Try using locale.getpreferredencoding git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43829 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/src/_core_ex.py | 5 ++++- wxPython/src/gtk/_core.py | 5 ++++- wxPython/src/mac/_core.py | 5 ++++- wxPython/src/msw/_core.py | 5 ++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/wxPython/src/_core_ex.py b/wxPython/src/_core_ex.py index bb3658d73c..bd9ecf759e 100644 --- a/wxPython/src/_core_ex.py +++ b/wxPython/src/_core_ex.py @@ -67,7 +67,10 @@ if default == 'ascii': import locale import codecs try: - default = locale.getdefaultlocale()[1] + if hasattr(locale, 'getpreferredencoding'): + default = locale.getpreferredencoding() + else: + default = locale.getdefaultlocale()[1] codecs.lookup(default) except (ValueError, LookupError, TypeError): default = _sys.getdefaultencoding() diff --git a/wxPython/src/gtk/_core.py b/wxPython/src/gtk/_core.py index e3e8e8d163..dbe7f46a8c 100644 --- a/wxPython/src/gtk/_core.py +++ b/wxPython/src/gtk/_core.py @@ -13709,7 +13709,10 @@ if default == 'ascii': import locale import codecs try: - default = locale.getdefaultlocale()[1] + if hasattr(locale, 'getpreferredencoding'): + default = locale.getpreferredencoding() + else: + default = locale.getdefaultlocale()[1] codecs.lookup(default) except (ValueError, LookupError, TypeError): default = _sys.getdefaultencoding() diff --git a/wxPython/src/mac/_core.py b/wxPython/src/mac/_core.py index e3e8e8d163..dbe7f46a8c 100644 --- a/wxPython/src/mac/_core.py +++ b/wxPython/src/mac/_core.py @@ -13709,7 +13709,10 @@ if default == 'ascii': import locale import codecs try: - default = locale.getdefaultlocale()[1] + if hasattr(locale, 'getpreferredencoding'): + default = locale.getpreferredencoding() + else: + default = locale.getdefaultlocale()[1] codecs.lookup(default) except (ValueError, LookupError, TypeError): default = _sys.getdefaultencoding() diff --git a/wxPython/src/msw/_core.py b/wxPython/src/msw/_core.py index e5794e1ae4..f9cf4a8438 100644 --- a/wxPython/src/msw/_core.py +++ b/wxPython/src/msw/_core.py @@ -13713,7 +13713,10 @@ if default == 'ascii': import locale import codecs try: - default = locale.getdefaultlocale()[1] + if hasattr(locale, 'getpreferredencoding'): + default = locale.getpreferredencoding() + else: + default = locale.getdefaultlocale()[1] codecs.lookup(default) except (ValueError, LookupError, TypeError): default = _sys.getdefaultencoding() -- 2.47.2