Hi all,
EPANET uses the strtod stdlib function to parse strings into floats/doubles. The strtod function is locale aware and, depending on the locale setting, uses commas or dots as the decimal separator.
That means that standard input files that use dots as decimal separator fail to open when the locale has been set to something other then the default "C". I've found this to happen when trying to integrate the EPANET toolkit into existing applications that set the locale.
Setting the locale to a language with a comma decimal separator will also result in an output file containing commas instead of dots:
I suggest for EPANET to only support dots as a decimal separator, though I'm unsure on the proper way to do that. One possibility is setting the locale before loading or writing input files, and restoring its setting directly after:
char *old_locale = setlocale(LC_NUMERIC, NULL);
setlocale(LC_NUMERIC, "C");
// Read input data
ERRCODE(getdata(pr));
setlocale(LC_NUMERIC, old_locale);
Hi all,
EPANET uses the
strtodstdlib function to parse strings into floats/doubles. Thestrtodfunction is locale aware and, depending on the locale setting, uses commas or dots as the decimal separator.That means that standard input files that use dots as decimal separator fail to open when the locale has been set to something other then the default "C". I've found this to happen when trying to integrate the EPANET toolkit into existing applications that set the locale.
Setting the locale to a language with a comma decimal separator will also result in an output file containing commas instead of dots:
I suggest for EPANET to only support dots as a decimal separator, though I'm unsure on the proper way to do that. One possibility is setting the locale before loading or writing input files, and restoring its setting directly after: