From 7bb7b0b16d9e5c896018b4eb803882cd60938c81 Mon Sep 17 00:00:00 2001 From: Sergey Kosov Date: Fri, 24 Mar 2017 12:03:15 +0100 Subject: [PATCH] Update json.cpp This update corrects the issue with parsing the floating-point numbers when the code is used under some non-en_US locales. --- .../source/thirdparty/supereasyjson/json.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/surround360_render/source/thirdparty/supereasyjson/json.cpp b/surround360_render/source/thirdparty/supereasyjson/json.cpp index 64b778a6..a3b2cdcf 100644 --- a/surround360_render/source/thirdparty/supereasyjson/json.cpp +++ b/surround360_render/source/thirdparty/supereasyjson/json.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #ifndef WIN32 #define _stricmp strcasecmp @@ -801,8 +802,13 @@ static Value DeserializeValue(std::string &str, bool *had_error, else if (has_e || has_dot) { char *end_char; errno = 0; - double d = strtod(temp_val.c_str(), &end_char); - if ((errno != 0) || (*end_char != '\0')) { + //double d = strtod(temp_val.c_str(), &end_char); + double d; + std::istringstream istr(temp_val); + istr.imbue(std::locale("en_US.utf8")); + istr >> d; + + if ((errno != 0) /*|| (*end_char != '\0')*/) { // invalid conversion or out of range *had_error = true; return Value();