Skip to content

Commit 315cf4e

Browse files
force the locale to be 'C'
1 parent 6d76774 commit 315cf4e

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src-lib/darknet_cfg_and_state.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "darknet_internal.hpp"
2+
#include <locale>
23

34
#ifdef WIN32
45
#define WIN32_LEAN_AND_MEAN
@@ -96,6 +97,14 @@ Darknet::CfgAndState & Darknet::CfgAndState::reset()
9697
std::srand(std::time(nullptr));
9798
// ... also see the seeding that happens in get_rnd_engine()
9899

100+
/* Some European locales use comma instead of period in the formatting of floats:
101+
*
102+
* 0,123 vs 0.123
103+
*
104+
* so force the locale to use the standard "C" locale and (hopefully!) avoid any parsing issues.
105+
*/
106+
std::setlocale(LC_ALL, "C");
107+
99108
/* Default is to use std::cout for console output. Do *NOT* call set_output_stream() from here,
100109
* since it will cause infinite recursion when it attempts to call CfgAndState::get().
101110
*/

0 commit comments

Comments
 (0)