#include "wx/log.h"
#endif
+#ifdef HAVE_LANGINFO_H
+ #include <langinfo.h>
+#endif
+
#ifdef __WXWINCE__
// there is no errno.h under CE apparently
#define wxSET_ERRNO(value)
using namespace std ;
#endif
+#if defined(__DARWIN__)
+ #include "wx/mac/corefoundation/cfref.h"
+ #include <CoreFoundation/CFLocale.h>
+ #include "wx/mac/corefoundation/cfstring.h"
+ #include <xlocale.h>
+#endif
+
#if wxUSE_WCHAR_T
WXDLLIMPEXP_BASE size_t wxMB2WC(wchar_t *buf, const char *psz, size_t n)
{
return NULL;
#else // !__WXWINCE__
+#ifdef __WXMAC__
+ char *rv = NULL ;
+ if ( locale != NULL && locale[0] == 0 )
+ {
+ locale_t lt = newlocale(LC_ALL_MASK, "", NULL);
+ if ( lt )
+ {
+ rv = (char*) querylocale( LC_ALL_MASK, lt );
+ freelocale(lt);
+ }
+ if ( rv == NULL || rv[0] == 0 || strcmp( rv , "C" ) == 0 || strcmp( rv, "POSIX" ) == 0 )
+ {
+ // we have to emulate the behaviour under OS X
+ wxCFRef<CFLocaleRef> userLocaleRef(CFLocaleCopyCurrent());
+ wxCFStringRef str(wxCFRetain((CFStringRef)CFLocaleGetValue(userLocaleRef, kCFLocaleLanguageCode)));
+ wxString langFull = str.AsString()+"_";
+ str.reset(wxCFRetain((CFStringRef)CFLocaleGetValue(userLocaleRef, kCFLocaleCountryCode)));
+ langFull += str.AsString();
+ rv = setlocale(category, langFull.c_str());
+ }
+ else
+ {
+ rv = setlocale(category, rv);
+ }
+ }
+ else
+ rv = setlocale(category, locale);
+#else
char *rv = setlocale(category, locale);
+#endif
if ( locale != NULL /* setting locale, not querying */ &&
rv /* call was successful */ )
{
return true;
}
}
-#endif
+#endif // HAVE_LANGINFO_H
// check if we're running under the "C" locale: it is 7bit subset
// of UTF-8, so it can be safely used with the UTF-8 build: