Use wxUILocale in wxNumberFormatter

Always use the UI locale conventions for floating point numbers in
wxNumberFormatter, making it different from wxString::{To,From}Double()
functions that use C locale, which may, or not, correspond to the UI
locale.
This commit is contained in:
Vadim Zeitlin
2021-08-05 18:30:30 +02:00
parent 37a23e1ab1
commit b3cab73680
2 changed files with 39 additions and 96 deletions

View File

@@ -8,11 +8,15 @@
/**
@class wxNumberFormatter
Helper class for formatting and parsing numbers with thousands separators.
Formatting and parsing numbers using the current UI locale conventions,
including support for using the correct decimal point character and
thousands separators.
This class contains only static functions, so users must not create instances
but directly call the member functions.
@see wxUILocale
@since 2.9.2
@library{wxbase}
@@ -32,7 +36,7 @@ public:
/**
If this flag is given, thousands separators will be inserted in the
number string representation as defined by the current locale.
number string representation as defined by the current UI locale.
*/
Style_WithThousandsSep = 0x01,
@@ -56,7 +60,7 @@ public:
Returns string representation of an integer number.
By default, the string will use thousands separators if appropriate for
the current locale. This can be avoided by passing Style_None as @a
the current UI locale. This can be avoided by passing Style_None as @a
flags in which case the call to the function has exactly the same
effect as <code>wxString::Format("%ld", val)</code>.
@@ -94,7 +98,7 @@ public:
Parse a string representation of a number possibly including thousands
separators.
These functions parse number representation in the current locale. On
These functions parse number representation in the current UI locale. On
success they return @true and store the result at the location pointed
to by @a val (which can't be @NULL), otherwise @false is returned.
@@ -114,7 +118,7 @@ public:
//@}
/**
Get the decimal separator for the current locale.
Get the decimal separator for the current UI locale.
Decimal separators is always defined and we fall back to returning '.'
in case of an error.
@@ -123,14 +127,14 @@ public:
/**
Get the thousands separator if grouping of the digits is used by the
current locale.
current UI locale.
The value returned in @a sep should be only used if the function
returns @true, otherwise no thousands separator should be used at all.
@param sep
Points to the variable receiving the thousands separator character
if it is used by the current locale. May be @NULL if only the
if it is used by the current UI locale. May be @NULL if only the
function return value is needed.
*/
static bool GetThousandsSeparatorIfUsed(wxChar *sep);