From: Václav Slavík Date: Tue, 22 Apr 2008 13:52:56 +0000 (+0000) Subject: restored wxOKlibc() for wxGTK1's use X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/960b1f9409f4a207f18ccdd63bec6ddb9a85cc39 restored wxOKlibc() for wxGTK1's use git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53314 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/gtk1/app.cpp b/src/gtk1/app.cpp index e0d50295b0..d2e2211643 100644 --- a/src/gtk1/app.cpp +++ b/src/gtk1/app.cpp @@ -399,6 +399,28 @@ void wxapp_install_idle_handler() wxTheApp->m_idleTag = gtk_idle_add_priority( 1000, wxapp_idle_callback, (gpointer) NULL ); } +static bool wxOKlibc() +{ +#if defined(__UNIX__) && defined(__GLIBC__) + // glibc 2.0 uses UTF-8 even when it shouldn't + wchar_t res = 0; + if ((MB_CUR_MAX == 2) && + (wxMB2WC(&res, "\xdd\xa5", 1) == 1) && + (res==0x765)) + { + // this is UTF-8 allright, check whether that's what we want + char *cur_locale = setlocale(LC_CTYPE, NULL); + if ((strlen(cur_locale) < 4) || + (strcasecmp(cur_locale + strlen(cur_locale) - 4, "utf8")) || + (strcasecmp(cur_locale + strlen(cur_locale) - 5, "utf-8"))) { + // nope, don't use libc conversion + return false; + } + } +#endif + return true; +} + //----------------------------------------------------------------------------- // Access to the root window global //----------------------------------------------------------------------------- @@ -573,13 +595,8 @@ bool wxApp::Initialize(int& argc, wxChar **argv) gtk_set_locale(); // We should have the wxUSE_WCHAR_T test on the _outside_ -#if wxUSE_WCHAR_T - if (!wxOKlibc()) - wxConvCurrent = &wxConvLocal; -#else // !wxUSE_WCHAR_T if (!wxOKlibc()) - wxConvCurrent = (wxMBConv*) NULL; -#endif // wxUSE_WCHAR_T/!wxUSE_WCHAR_T + wxConvCurrent = &wxConvLocal; #if wxUSE_UNICODE // gtk_init() wants UTF-8, not wchar_t, so convert