bool wxNumberFormatter::GetThousandsSeparatorIfUsed(wxChar *sep) { #if wxUSE_INTL static wxChar s_thousandsSeparator = 0; static LocaleId s_localeUsedForInit; if ( s_localeUsedForInit.NotInitializedOrHasChanged() ) { const wxString s = wxLocale::GetInfo(wxLOCALE_THOUSANDS_SEP, wxLOCALE_CAT_NUMBER); if ( s.length() == 1 ) { s_thousandsSeparator = s[0]; } //else: Unlike above it's perfectly fine for the thousands separator to // be empty if grouping is not used, so just leave it as 0. } if ( !s_thousandsSeparator ) return false; if ( sep ) *sep = s_thousandsSeparator; return true; #else // !wxUSE_INTL wxUnusedVar(sep); return false; #endif // wxUSE_INTL/!wxUSE_INTL }
wxChar wxNumberFormatter::GetDecimalSeparator() { // Notice that while using static variable here is not MT-safe, the worst // that can happen is that we redo the initialization if we're called // concurrently from more than one thread so it's not a real problem. static wxChar s_decimalSeparator = 0; // Remember the locale which was current when we initialized, we must redo // the initialization if the locale changed. static LocaleId s_localeUsedForInit; if ( s_localeUsedForInit.NotInitializedOrHasChanged() ) { const wxString s = wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT, wxLOCALE_CAT_NUMBER); if ( s.empty() ) { // We really must have something for decimal separator, so fall // back to the C locale default. s_decimalSeparator = '.'; } else { // To the best of my knowledge there are no locales like this. wxASSERT_MSG( s.length() == 1, "Multi-character decimal separator?" ); s_decimalSeparator = s[0]; } } return s_decimalSeparator; }
wxChar wxNumberFormatter::GetDecimalSeparator() { #if wxUSE_INTL // Notice that while using static variable here is not MT-safe, the worst // that can happen is that we redo the initialization if we're called // concurrently from more than one thread so it's not a real problem. static wxChar s_decimalSeparator = 0; // Remember the locale which was current when we initialized, we must redo // the initialization if the locale changed. static LocaleId s_localeUsedForInit; if ( s_localeUsedForInit.NotInitializedOrHasChanged() ) { const wxString s = wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT, wxLOCALE_CAT_NUMBER); if ( s.length() == 1 ) { s_decimalSeparator = s[0]; } else { // We really must have something for decimal separator, so fall // back to the C locale default. s_decimalSeparator = '.'; } } return s_decimalSeparator; #else // !wxUSE_INTL return wxT('.'); #endif // wxUSE_INTL/!wxUSE_INTL }
bool wxNumberFormatter::GetThousandsSeparatorIfUsed(wxChar *sep) { static wxChar s_thousandsSeparator = 0; static LocaleId s_localeUsedForInit; if ( s_localeUsedForInit.NotInitializedOrHasChanged() ) { const wxString s = wxLocale::GetInfo(wxLOCALE_THOUSANDS_SEP, wxLOCALE_CAT_NUMBER); if ( !s.empty() ) { wxASSERT_MSG( s.length() == 1, "Multi-character thousands separator?" ); s_thousandsSeparator = s[0]; } //else: Unlike above it's perfectly fine for the thousands separator to // be empty if grouping is not used, so just leave it as 0. } if ( !s_thousandsSeparator ) return false; if ( sep ) *sep = s_thousandsSeparator; return true; }