From 850a256b833831d58f3ac8479348033b8a159aae Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 26 May 2013 13:14:35 +0000 Subject: [PATCH] Use C locale representation for floating point numbers in wxAny. Always use the decimal point, regardless of the current locale. This completes the changes of r74019. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74054 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 3 +++ interface/wx/any.h | 5 +++++ src/common/any.cpp | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/changes.txt b/docs/changes.txt index adc9b79eb5..03eeb53fd3 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -236,6 +236,9 @@ Changes in behaviour not resulting in compilation errors, please read this! GetEventObject() in all ports but the frame the menu was attached to in wxMSW. Now all ports return the menu that was opened or closed as the event object. +- wxAny now uses C locale format for the floating point numbers and not the + current locale one, i.e. decimal point is always used. + Changes in behaviour which may result in compilation errors ----------------------------------------------------------- diff --git a/interface/wx/any.h b/interface/wx/any.h index de177e1430..e8b5c6da5f 100644 --- a/interface/wx/any.h +++ b/interface/wx/any.h @@ -48,6 +48,11 @@ object in heap for large objects (i.e. ones with size more than WX_ANY_VALUE_BUFFER_SIZE, which at the time of writing is 16 bytes). + @note When performing conversions between strings and floating point + numbers, the representation of numbers in C locale is always used. + I.e. @code wxAny("1.23").GetAs() @endcode will always work, + even if the current locale uses comma as decimal separator. + @library{wxbase} @category{data} diff --git a/src/common/any.cpp b/src/common/any.cpp index 074412c80e..cefcc2a1d8 100644 --- a/src/common/any.cpp +++ b/src/common/any.cpp @@ -453,7 +453,7 @@ bool wxAnyValueTypeImplDouble::ConvertValue(const wxAnyValueBuffer& src, } else if ( wxANY_VALUE_TYPE_CHECK_TYPE(dstType, wxString) ) { - wxString s = wxString::Format(wxS("%.14g"), value); + wxString s = wxString::FromCDouble(value, 14); wxAnyValueTypeImpl::SetValue(s, dst); } else -- 2.45.2