+ break;
+
+ default:
+ wxFAIL_MSG( "Unknown locale info" );
+ return wxString();
+ }
+
+ wxCFStringRef str(wxCFRetain(cfstr));
+ return str.AsString();
+}
+
+#else // !__WXMSW__ && !__WXOSX__, assume generic POSIX
+
+namespace
+{
+
+wxString GetDateFormatFromLangInfo(wxLocaleInfo index)
+{
+#ifdef HAVE_LANGINFO_H
+ // array containing parameters for nl_langinfo() indexes by offset of index
+ // from wxLOCALE_SHORT_DATE_FMT
+ static const nl_item items[] =
+ {
+ D_FMT, D_T_FMT, D_T_FMT, T_FMT,
+ };
+
+ const int nlidx = index - wxLOCALE_SHORT_DATE_FMT;
+ if ( nlidx < 0 || nlidx >= (int)WXSIZEOF(items) )
+ {
+ wxFAIL_MSG( "logic error in GetInfo() code" );
+ return wxString();
+ }
+
+ const wxString fmt(nl_langinfo(items[nlidx]));
+
+ // just return the format returned by nl_langinfo() except for long date
+ // format which we need to recover from date/time format ourselves (but not
+ // if we failed completely)
+ if ( fmt.empty() || index != wxLOCALE_LONG_DATE_FMT )
+ return fmt;
+
+ // this is not 100% precise but the idea is that a typical date/time format
+ // under POSIX systems is a combination of a long date format with time one
+ // so we should be able to get just the long date format by removing all
+ // time-specific format specifiers
+ static const char *timeFmtSpecs = "HIklMpPrRsSTXzZ";
+ static const char *timeSep = " :./-";
+
+ wxString fmtDateOnly;
+ const wxString::const_iterator end = fmt.end();
+ wxString::const_iterator lastSep = end;
+ for ( wxString::const_iterator p = fmt.begin(); p != end; ++p )
+ {
+ if ( strchr(timeSep, *p) )
+ {
+ if ( lastSep == end )
+ lastSep = p;
+
+ // skip it for now, we'll discard it if it's followed by a time
+ // specifier later or add it to fmtDateOnly if it is not
+ continue;
+ }
+
+ if ( *p == '%' &&
+ (p + 1 != end) && strchr(timeFmtSpecs, p[1]) )
+ {
+ // time specified found: skip it and any preceding separators
+ ++p;
+ lastSep = end;
+ continue;
+ }
+
+ if ( lastSep != end )
+ {
+ fmtDateOnly += wxString(lastSep, p);
+ lastSep = end;
+ }
+
+ fmtDateOnly += *p;
+ }
+
+ return fmtDateOnly;
+#else // !HAVE_LANGINFO_H
+ wxUnusedVar(index);
+
+ // no fallback, let the application deal with unavailability of
+ // nl_langinfo() itself as there is no good way for us to do it (well, we
+ // could try to reverse engineer the format from strftime() output but this
+ // looks like too much trouble considering the relatively small number of
+ // systems without nl_langinfo() still in use)
+ return wxString();
+#endif // HAVE_LANGINFO_H/!HAVE_LANGINFO_H
+}
+
+} // anonymous namespace
+
+/* static */
+wxString wxLocale::GetInfo(wxLocaleInfo index, wxLocaleCategory cat)
+{
+ lconv * const lc = localeconv();
+ if ( !lc )
+ return wxString();
+
+ switch ( index )
+ {
+ case wxLOCALE_THOUSANDS_SEP:
+ if ( cat == wxLOCALE_CAT_NUMBER )
+ return lc->thousands_sep;
+ else if ( cat == wxLOCALE_CAT_MONEY )
+ return lc->mon_thousands_sep;
+
+ wxFAIL_MSG( "invalid wxLocaleCategory" );
+ break;
+
+
+ case wxLOCALE_DECIMAL_POINT:
+ if ( cat == wxLOCALE_CAT_NUMBER )
+ return lc->decimal_point;
+ else if ( cat == wxLOCALE_CAT_MONEY )
+ return lc->mon_decimal_point;
+
+ wxFAIL_MSG( "invalid wxLocaleCategory" );
+ break;
+
+ case wxLOCALE_SHORT_DATE_FMT:
+ case wxLOCALE_LONG_DATE_FMT:
+ case wxLOCALE_DATE_TIME_FMT:
+ case wxLOCALE_TIME_FMT:
+ if ( cat != wxLOCALE_CAT_DATE && cat != wxLOCALE_CAT_DEFAULT )