From 1d9473d33b40eb82d017b09b544428f6a6bd2749 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 9 Sep 2007 22:24:43 +0000 Subject: [PATCH] don't change locale in XRC GetFloat() method, change the strings to use the current locale decimal point separator instead (patch 1783849) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48620 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/xrc/xmlres.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/xrc/xmlres.cpp b/src/xrc/xmlres.cpp index 5a024457b6..64286184e4 100644 --- a/src/xrc/xmlres.cpp +++ b/src/xrc/xmlres.cpp @@ -960,20 +960,20 @@ long wxXmlResourceHandler::GetLong(const wxString& param, long defaultv) float wxXmlResourceHandler::GetFloat(const wxString& param, float defaultv) { - double value; - wxString str1 = GetParamValue(param); + wxString str = GetParamValue(param); -#ifndef __WXWINCE__ - const char *prevlocale = setlocale(LC_NUMERIC, "C"); -#endif + // strings in XRC always use C locale but wxString::ToDouble() uses the + // current one, so transform the string to it supposing that the only + // difference between them is the decimal separator + // + // TODO: use wxString::ToCDouble() when we have it + str.Replace(wxT("."), wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT, + wxLOCALE_CAT_NUMBER)); - if (!str1.ToDouble(&value)) + double value; + if (!str.ToDouble(&value)) value = defaultv; -#ifndef __WXWINCE__ - setlocale(LC_NUMERIC, prevlocale); -#endif - return wx_truncate_cast(float, value); } -- 2.45.2