From 0043f42027c6f5ed65f3d68bfcc024c0cf653577 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 23 Aug 2011 11:04:37 +0000 Subject: [PATCH] Check for decimal separator inconsistency in wxLocale::GetInfo(). Under wxMSW it's possible to have mismatch between the CRT locale (used by various printf-related functions) and the system locale (queried by wxLocale::GetInfo()). Warn if such a mismatch occurs and tell people to use wxLocale instead of just setlocale() to change the locale. See #12970. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68861 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/intl.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/common/intl.cpp b/src/common/intl.cpp index 9b38ffbf14..97cb520a39 100644 --- a/src/common/intl.cpp +++ b/src/common/intl.cpp @@ -1442,7 +1442,23 @@ wxString wxLocale::GetInfo(wxLocaleInfo index, wxLocaleCategory cat) : LOCALE_SDECIMAL, buf, WXSIZEOF(buf)) ) + { str = buf; + + // As we get our decimal point separator from Win32 and not the + // CRT there is a possibility of mismatch between them and this + // can easily happen if the user code called setlocale() + // instead of using wxLocale to change the locale. And this can + // result in very strange bugs elsewhere in the code as the + // assumptions that formatted strings do use the decimal + // separator actually fail, so check for it here. + wxASSERT_MSG + ( + wxString::Format("%.3f", 1.23).find(str) != wxString::npos, + "Decimal separator mismatch -- did you use setlocale()?" + "If so, use wxLocale to change the locale instead." + ); + } break; case wxLOCALE_SHORT_DATE_FMT: