X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3aefa658c81b577181fc7440f1b25c9aec2a561a..cc402e6431b66a8eb7d567caa55a1bece42902b7:/src/common/intl.cpp diff --git a/src/common/intl.cpp b/src/common/intl.cpp index 820a7d6bad..6e9a036564 100644 --- a/src/common/intl.cpp +++ b/src/common/intl.cpp @@ -28,6 +28,12 @@ #pragma option -O1 #endif +#ifdef __EMX__ +// The following define is needed by Innotek's libc to +// make the definition of struct localeconv available. +#define __INTERNAL_DEFS +#endif + // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -1370,7 +1376,7 @@ wxLanguageInfoArray *wxLocale::ms_languagesDB = NULL; } -wxLocale::wxLocale() +void wxLocale::DoCommonInit() { m_pszOldLocale = NULL; m_pMsgCat = NULL; @@ -1418,9 +1424,11 @@ bool wxLocale::Init(const wxChar *szName, // TODO: how to find languageId // SetLocaleInfo(languageId, SORT_DEFAULT, localeName); #else - m_pszOldLocale = wxSetlocale(LC_ALL, szLocale); - if ( m_pszOldLocale ) - m_pszOldLocale = wxStrdup(m_pszOldLocale); + wxMB2WXbuf oldLocale = wxSetlocale(LC_ALL, szLocale); + if ( oldLocale ) + m_pszOldLocale = wxStrdup(oldLocale); + else + m_pszOldLocale = NULL; #endif if ( m_pszOldLocale == NULL ) @@ -2245,7 +2253,13 @@ wxFontEncoding wxLocale::GetSystemEncoding() return wxFONTENCODING_CP950; } #elif defined(__WXMAC__) - return wxMacGetFontEncFromSystemEnc( CFStringGetSystemEncoding() ) ; + TextEncoding encoding = 0 ; +#if TARGET_CARBON + encoding = CFStringGetSystemEncoding() ; +#else + UpgradeScriptInfoToTextEncoding ( smSystemScript , kTextLanguageDontCare , kTextRegionDontCare , NULL , &encoding ) ; +#endif + return wxMacGetFontEncFromSystemEnc( encoding ) ; #elif defined(__UNIX_LIKE__) && wxUSE_FONTMAP wxString encname = GetSystemEncodingName(); if ( !encname.empty() ) @@ -2501,12 +2515,10 @@ bool wxLocale::AddCatalog(const wxChar *szDomain) // accessors for locale-dependent data // ---------------------------------------------------------------------------- -#if 0 - #ifdef __WXMSW__ /* static */ -wxString wxLocale::GetInfo(wxLocaleInfo index) +wxString wxLocale::GetInfo(wxLocaleInfo index, wxLocaleCategory WXUNUSED(cat)) { wxString str; wxChar buffer[256]; @@ -2514,29 +2526,31 @@ wxString wxLocale::GetInfo(wxLocaleInfo index) buffer[0] = wxT('\0'); switch (index) { - case wxSYS_DECIMAL_SEPARATOR: + case wxLOCALE_DECIMAL_POINT: count = ::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buffer, 256); if (!count) - str << "."; + str << wxT("."); else str << buffer; break; +#if 0 case wxSYS_LIST_SEPARATOR: count = ::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SLIST, buffer, 256); if (!count) - str << ","; + str << wxT(","); else str << buffer; break; case wxSYS_LEADING_ZERO: // 0 means no leading zero, 1 means leading zero count = ::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_ILZERO, buffer, 256); if (!count) - str << "0"; + str << wxT("0"); else str << buffer; break; +#endif default: - wxFAIL_MSG("Unknown System String !"); + wxFAIL_MSG(wxT("Unknown System String !")); } return str; } @@ -2544,15 +2558,42 @@ wxString wxLocale::GetInfo(wxLocaleInfo index) #else // !__WXMSW__ /* static */ -wxString wxLocale::GetInfo(wxLocaleInfo index, wxLocaleCategory) +wxString wxLocale::GetInfo(wxLocaleInfo index, wxLocaleCategory cat) { - return wxEmptyString; -} + struct lconv *locale_info = localeconv(); + switch (cat) + { + case wxLOCALE_CAT_NUMBER: + switch (index) + { + case wxLOCALE_THOUSANDS_SEP: + return wxString(locale_info->thousands_sep, + *wxConvCurrent); + case wxLOCALE_DECIMAL_POINT: + return wxString(locale_info->decimal_point, + *wxConvCurrent); + default: + return wxEmptyString; + } + case wxLOCALE_CAT_MONEY: + switch (index) + { + case wxLOCALE_THOUSANDS_SEP: + return wxString(locale_info->mon_thousands_sep, + *wxConvCurrent); + case wxLOCALE_DECIMAL_POINT: + return wxString(locale_info->mon_decimal_point, + *wxConvCurrent); + default: + return wxEmptyString; + } + default: + return wxEmptyString; + } +} #endif // __WXMSW__/!__WXMSW__ -#endif // 0 - // ---------------------------------------------------------------------------- // global functions and variables // ----------------------------------------------------------------------------