mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-06-27 08:25:37 +02:00
fix numeric locale
In some locales (e.g. de_DE) floats have commas instead of dots, but JSON requires dots. 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
49c732607b
commit
496c655523
@ -68,6 +68,20 @@ static inline void uintToString(LargestUInt value, char *¤t) {
|
|||||||
} while (value != 0);
|
} while (value != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Change ',' to '.' everywhere in buffer.
|
||||||
|
*
|
||||||
|
* We had a sophisticated way, but it did not work in WinCE.
|
||||||
|
* @see https://github.com/open-source-parsers/jsoncpp/pull/9
|
||||||
|
*/
|
||||||
|
static inline void fixNumericLocale(char* begin, char* end) {
|
||||||
|
while (begin < end) {
|
||||||
|
if (*begin == ',') {
|
||||||
|
*begin = '.';
|
||||||
|
}
|
||||||
|
++begin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Json {
|
} // namespace Json {
|
||||||
|
|
||||||
#endif // LIB_JSONCPP_JSON_TOOL_H_INCLUDED
|
#endif // LIB_JSONCPP_JSON_TOOL_H_INCLUDED
|
||||||
|
@ -77,7 +77,7 @@ std::string valueToString(double value) {
|
|||||||
#else
|
#else
|
||||||
snprintf(buffer, sizeof(buffer), "%.16g", value);
|
snprintf(buffer, sizeof(buffer), "%.16g", value);
|
||||||
#endif
|
#endif
|
||||||
|
fixNumericLocale(buffer, buffer + strlen(buffer));
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user