From 3a12b759c9262ae0c4e2fca5adaf5feab573d716 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Tue, 4 Dec 2007 17:49:29 +0000 Subject: [PATCH] emulate expected setlocale(0,"") behaviour git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50470 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/wxcrt.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/common/wxcrt.cpp b/src/common/wxcrt.cpp index 52f825b75a..d7de48de96 100644 --- a/src/common/wxcrt.cpp +++ b/src/common/wxcrt.cpp @@ -61,6 +61,12 @@ namespace std {} using namespace std ; #endif +#if defined(__DARWIN__) + #include "wx/mac/corefoundation/cfref.h" + #include + #include "wx/mac/corefoundation/cfstring.h" +#endif + #if wxUSE_WCHAR_T WXDLLIMPEXP_BASE size_t wxMB2WC(wchar_t *buf, const char *psz, size_t n) { @@ -153,7 +159,23 @@ char* wxSetlocale(int category, const char *locale) return NULL; #else // !__WXWINCE__ +#ifdef __WXMAC__ + char *rv = NULL ; + if ( locale != NULL && locale[0] == 0 ) + { + // we have to emulate the behaviour under OS X + wxCFRef userLocaleRef(CFLocaleCopyCurrent()); + wxMacCFStringHolder str(wxCFRetain((CFStringRef)CFLocaleGetValue(userLocaleRef, kCFLocaleLanguageCode))); + wxString langFull = str.AsString()+"_"; + str.Assign(wxCFRetain((CFStringRef)CFLocaleGetValue(userLocaleRef, kCFLocaleCountryCode))); + langFull += str.AsString(); + rv = setlocale(category, langFull.c_str()); + } + else + rv = setlocale(category, locale); +#else char *rv = setlocale(category, locale); +#endif if ( locale != NULL /* setting locale, not querying */ && rv /* call was successful */ ) { -- 2.45.2