mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2024-12-28 20:15:24 +08:00
Revert "Merge pull request #7 from steffen-kiess/fix-locale"
This reverts commit 0db9d6ea013792b010c598c2a9a3a9e39a2decd9, reversing changes made to 06dcb1fc8922991919887e229fdd741bccde0dfa. For discussion, see https://github.com/open-source-parsers/jsoncpp/pull/9 https://github.com/open-source-parsers/jsoncpp/pull/3
This commit is contained in:
parent
655a9db0cc
commit
49c732607b
@ -63,15 +63,22 @@ std::string valueToString(UInt value) {
|
|||||||
#endif // # if defined(JSON_HAS_INT64)
|
#endif // # if defined(JSON_HAS_INT64)
|
||||||
|
|
||||||
std::string valueToString(double value) {
|
std::string valueToString(double value) {
|
||||||
// We need not request the alternative representation
|
// Allocate a buffer that is more than large enough to store the 16 digits of
|
||||||
// that always has a decimal point because JSON doesn't distingish the
|
// precision requested below.
|
||||||
// concepts of reals and integers.
|
char buffer[32];
|
||||||
std::stringstream str;
|
|
||||||
// Set locale to "C" to always get a '.' instead of a ','
|
// Print into the buffer. We need not request the alternative representation
|
||||||
str.imbue(std::locale::classic());
|
// that always has a decimal point because JSON doesn't distingish the
|
||||||
str.precision(16);
|
// concepts of reals and integers.
|
||||||
str << value;
|
#if defined(_MSC_VER) && defined(__STDC_SECURE_LIB__) // Use secure version with
|
||||||
return str.str();
|
// visual studio 2005 to
|
||||||
|
// avoid warning.
|
||||||
|
sprintf_s(buffer, sizeof(buffer), "%.16g", value);
|
||||||
|
#else
|
||||||
|
snprintf(buffer, sizeof(buffer), "%.16g", value);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string valueToString(bool value) { return value ? "true" : "false"; }
|
std::string valueToString(bool value) { return value ? "true" : "false"; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user