File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -63,22 +63,15 @@ std::string valueToString(UInt value) {
6363#endif // # if defined(JSON_HAS_INT64)
6464
6565std::string valueToString (double value) {
66- // Allocate a buffer that is more than large enough to store the 16 digits of
67- // precision requested below.
68- char buffer[32 ];
69-
70- // Print into the buffer. We need not request the alternative representation
71- // that always has a decimal point because JSON doesn't distingish the
72- // concepts of reals and integers.
73- #if defined(_MSC_VER) && defined(__STDC_SECURE_LIB__) // Use secure version with
74- // visual studio 2005 to
75- // avoid warning.
76- sprintf_s (buffer, sizeof (buffer), " %.16g" , value);
77- #else
78- snprintf (buffer, sizeof (buffer), " %.16g" , value);
79- #endif
80-
81- return buffer;
66+ // We need not request the alternative representation
67+ // that always has a decimal point because JSON doesn't distingish the
68+ // concepts of reals and integers.
69+ std::stringstream str;
70+ // Set locale to "C" to always get a '.' instead of a ','
71+ str.imbue (std::locale::classic ());
72+ str.precision (16 );
73+ str << value;
74+ return str.str ();
8275}
8376
8477std::string valueToString (bool value) { return value ? " true" : " false" ; }
You can’t perform that action at this time.
0 commit comments