mirror of
https://github.com/nlohmann/json
synced 2024-12-04 09:10:05 +00:00
Bugfix: when working with C formatting functions we need to query C locales (localeconv) rather than std::locale
This commit is contained in:
parent
e41a956782
commit
d643360575
12
src/json.hpp
12
src/json.hpp
@ -9108,7 +9108,7 @@ basic_json_parser_66:
|
||||
// this is a helper to determine whether to
|
||||
// parse the token into floating-point or
|
||||
// integral type. We wouldn't need it if
|
||||
// we had separate token types for interal
|
||||
// we had separate token types for integral
|
||||
// and floating-point cases.
|
||||
bool is_integral() const
|
||||
{
|
||||
@ -9172,9 +9172,19 @@ basic_json_parser_66:
|
||||
const char* data = m_start;
|
||||
const size_t len = static_cast<size_t>(m_end - m_start);
|
||||
|
||||
#if 0
|
||||
const char decimal_point_char =
|
||||
std::use_facet< std::numpunct<char> >(
|
||||
std::locale()).decimal_point();
|
||||
#else
|
||||
// Since dealing with strtod family of functions,
|
||||
// need to use the C locales instead of C++
|
||||
const auto loc = localeconv();
|
||||
assert(loc != nullptr);
|
||||
const char decimal_point_char =
|
||||
!loc->decimal_point ? '.'
|
||||
: loc->decimal_point[0];
|
||||
#endif
|
||||
|
||||
// replace decimal separator with locale-specific
|
||||
// version, when necessary; data will be repointed
|
||||
|
@ -8257,7 +8257,7 @@ class basic_json
|
||||
// this is a helper to determine whether to
|
||||
// parse the token into floating-point or
|
||||
// integral type. We wouldn't need it if
|
||||
// we had separate token types for interal
|
||||
// we had separate token types for integral
|
||||
// and floating-point cases.
|
||||
bool is_integral() const
|
||||
{
|
||||
@ -8321,9 +8321,19 @@ class basic_json
|
||||
const char* data = m_start;
|
||||
const size_t len = static_cast<size_t>(m_end - m_start);
|
||||
|
||||
#if 0
|
||||
const char decimal_point_char =
|
||||
std::use_facet< std::numpunct<char> >(
|
||||
std::locale()).decimal_point();
|
||||
#else
|
||||
// Since dealing with strtod family of functions,
|
||||
// need to use the C locales instead of C++
|
||||
const auto loc = localeconv();
|
||||
assert(loc != nullptr);
|
||||
const char decimal_point_char =
|
||||
!loc->decimal_point ? '.'
|
||||
: loc->decimal_point[0];
|
||||
#endif
|
||||
|
||||
// replace decimal separator with locale-specific
|
||||
// version, when necessary; data will be repointed
|
||||
|
Loading…
Reference in New Issue
Block a user