From 41524ffcc69b963ea8a5c37fceaa312dfdeb905f Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Mon, 7 Jul 2003 08:28:44 +0000 Subject: [PATCH] applied modified UTF-8 locales patch (766893) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21735 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + docs/toback24.txt | 13 +++++++++++++ src/common/intl.cpp | 26 ++++++++++++++++++++++---- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index d1703b0c8e..c30903e627 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -105,6 +105,7 @@ Unix: - fixed compilation on Solaris 7 with large files support enabled - added wxTaskBarIcon implementation for X11 - added support for GNU/Hurd in configure +- wxLocale::Init now tries to set .utf8 locale in Unicode mode (Andreas Pflug) wxGTK: diff --git a/docs/toback24.txt b/docs/toback24.txt index 182f55a2f1..83d2c07654 100644 --- a/docs/toback24.txt +++ b/docs/toback24.txt @@ -213,6 +213,19 @@ Checking in src/msw/window.cpp; new revision: 1.381; previous revision: 1.380 done +24. Fix wxLocale::Init to try xx_YY.utf8 on systems where xx_YY fails +(presumably RedHat; do it in Unicode mode only) + +See: Patch [ 766893 ] +Checking in intl.cpp; +/pack/cvsroots/wxwindows/wxWindows/src/common/intl.cpp,v <-- intl.cpp +new revision: 1.97; previous revision: 1.96 +done +Checking in changes.txt; +/pack/cvsroots/wxwindows/wxWindows/docs/changes.txt,v <-- changes.txt +new revision: 1.297; previous revision: 1.296 +done + TODO for 2.4 (items that are not backports) =========================================== diff --git a/src/common/intl.cpp b/src/common/intl.cpp index 684c9a5f25..69178b2abc 100644 --- a/src/common/intl.cpp +++ b/src/common/intl.cpp @@ -141,6 +141,7 @@ static inline wxString ExtractNotLang(const wxString& langFull) #endif // __UNIX__ + // ---------------------------------------------------------------------------- // wxMsgCatalogFile corresponds to one disk-file message catalog. // @@ -644,6 +645,23 @@ bool wxLocale::Init(const wxChar *szName, return bOk; } + +#if defined(__UNIX__) && wxUSE_UNICODE +static wxWCharBuffer wxSetlocaleTryUTF(int c, const wxChar *lc) +{ + wxMB2WXbuf l = wxSetlocale(c, lc); + if ( lc && lc[0] != 0 && !l ) + { + wxString buf(lc); + buf += wxT(".utf8"); + l = wxSetlocale(c, buf.c_str()); + } + return l; +} +#else +#define wxSetlocaleTryUTF(c, lc) wxSetlocale(c, lc) +#endif + bool wxLocale::Init(int language, int flags) { int lang = language; @@ -679,12 +697,12 @@ bool wxLocale::Init(int language, int flags) else locale = info->CanonicalName; - wxMB2WXbuf retloc = wxSetlocale(LC_ALL, locale); + wxMB2WXbuf retloc = wxSetlocaleTryUTF(LC_ALL, locale); if ( !retloc ) { // Some C libraries don't like xx_YY form and require xx only - retloc = wxSetlocale(LC_ALL, locale.Mid(0,2)); + retloc = wxSetlocaleTryUTF(LC_ALL, locale.Mid(0,2)); } if ( !retloc ) { @@ -702,13 +720,13 @@ bool wxLocale::Init(int language, int flags) else if (mid == wxT("nn")) locale = wxT("no_NY"); - retloc = wxSetlocale(LC_ALL, locale); + retloc = wxSetlocaleTryUTF(LC_ALL, locale); } if ( !retloc ) { // (This time, we changed locale in previous if-branch, so try again.) // Some C libraries don't like xx_YY form and require xx only - retloc = wxSetlocale(LC_ALL, locale.Mid(0,2)); + retloc = wxSetlocaleTryUTF(LC_ALL, locale.Mid(0,2)); } if ( !retloc ) { -- 2.45.2