Merge pull request #2733 from AdmiralCurtiss/string-from-float
IniFile: Fix floating point number locale issues.
This commit is contained in:
commit
3ed29cce0c
|
@ -46,12 +46,12 @@ public:
|
||||||
|
|
||||||
void Set(const std::string& key, float newValue)
|
void Set(const std::string& key, float newValue)
|
||||||
{
|
{
|
||||||
Set(key, StringFromFormat("%f", newValue));
|
Set(key, StringFromFormat("%#.9g", newValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Set(const std::string& key, double newValue)
|
void Set(const std::string& key, double newValue)
|
||||||
{
|
{
|
||||||
Set(key, StringFromFormat("%f", newValue));
|
Set(key, StringFromFormat("%#.17g", newValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Set(const std::string& key, int newValue)
|
void Set(const std::string& key, int newValue)
|
||||||
|
|
|
@ -82,10 +82,10 @@ bool CharArrayFromFormatV(char* out, int outsize, const char* format, va_list ar
|
||||||
// multibyte handling is required as we can simply assume that no '%' char
|
// multibyte handling is required as we can simply assume that no '%' char
|
||||||
// will be present in the middle of a multibyte sequence.
|
// will be present in the middle of a multibyte sequence.
|
||||||
//
|
//
|
||||||
// This is why we lookup an ANSI (cp1252) locale here and use _vsnprintf_l.
|
// This is why we look up the default C locale here and use _vsnprintf_l.
|
||||||
static _locale_t c_locale = nullptr;
|
static _locale_t c_locale = nullptr;
|
||||||
if (!c_locale)
|
if (!c_locale)
|
||||||
c_locale = _create_locale(LC_ALL, ".1252");
|
c_locale = _create_locale(LC_ALL, "C");
|
||||||
writtenCount = _vsnprintf_l(out, outsize, format, c_locale, args);
|
writtenCount = _vsnprintf_l(out, outsize, format, c_locale, args);
|
||||||
#else
|
#else
|
||||||
#if !defined(ANDROID)
|
#if !defined(ANDROID)
|
||||||
|
|
Loading…
Reference in New Issue