Re: locale affects (infects? ;) strtod()



Tim> if strtod() can't be used to parse _international_ *rc files,
Tim> which function should be used instead to do string->float
Tim> conversions?

As you've discovered, strtod() does locale-specific conversion.  If
you want to use the C locale rules, then set the locale to C before
calling strtod().  You only have to set LC_NUMERIC:

	#include <locale.h>

	char *old = setlocale (LC_NUMERIC, "C");
	... strtod (...)   /* will use C rules */
	setlocale (LC_NUMERIC, old);

Tom



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]