void wxNumberFormatter::AddThousandsSeparators(wxString& s) { // Thousands separators for numbers in scientific format are not relevant. if ( s.find_first_of("eE") != wxString::npos ) return; wxChar thousandsSep; if ( !GetThousandsSeparatorIfUsed(&thousandsSep) ) return; size_t pos = s.find(GetDecimalSeparator()); if ( pos == wxString::npos ) { // Start grouping at the end of an integer number. pos = s.length(); } // End grouping at the beginning of the digits -- there could be at a sign // before their start. const size_t start = s.find_first_of("0123456789"); // We currently group digits by 3 independently of the locale. This is not // the right thing to do and we should use lconv::grouping (under POSIX) // and GetLocaleInfo(LOCALE_SGROUPING) (under MSW) to get information about // the correct grouping to use. This is something that needs to be done at // wxLocale level first and then used here in the future (TODO). const size_t GROUP_LEN = 3; while ( pos > start + GROUP_LEN ) { pos -= GROUP_LEN; s.insert(pos, thousandsSep); } }
void wxNumberFormatter::AddThousandsSeparators(wxString& s) { wxChar thousandsSep; if ( !GetThousandsSeparatorIfUsed(&thousandsSep) ) return; size_t pos = s.find(GetDecimalSeparator()); if ( pos == wxString::npos ) { // Start grouping at the end of an integer number. pos = s.length(); } // We currently group digits by 3 independently of the locale. This is not // the right thing to do and we should use lconv::grouping (under POSIX) // and GetLocaleInfo(LOCALE_SGROUPING) (under MSW) to get information about // the correct grouping to use. This is something that needs to be done at // wxLocale level first and then used here in the future (TODO). const size_t GROUP_LEN = 3; while ( pos > GROUP_LEN ) { pos -= GROUP_LEN; s.insert(pos, thousandsSep); } }
void wxNumberFormatter::RemoveThousandsSeparators(wxString& s) { wxChar thousandsSep; if ( !GetThousandsSeparatorIfUsed(&thousandsSep) ) return; s.Replace(wxString(thousandsSep), wxString()); }