Skip to content

Commit

Permalink
Use C locale for numeric values
Browse files Browse the repository at this point in the history
This is needed to make sure `std::to_string` will serialize
correctly, independent of the user's actual used locale.
  • Loading branch information
besser82 committed May 25, 2018
1 parent fb1b5d3 commit 2afac83
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/shogun/io/SerializableJsonFile.cpp
Expand Up @@ -104,6 +104,14 @@ CSerializableJsonFile::init(const char* fname)
m_stack_stream.push_back(buf);
break;
case 'w':
/*
* The C locale will be used for numeric values.
* This is needed to make sure `std::to_string`
* will serialize correctly, independent of the
* user's actual used locale.
*/
std::setlocale(LC_NUMERIC, "C");

m_stack_stream.push_back(json_object_new_object());
buf = json_object_new_string(STR_FILETYPE_00);
json_object_object_add(m_stack_stream.back(),
Expand Down

0 comments on commit 2afac83

Please sign in to comment.