Subject: setlocale
From: Dom Lachowicz (
Date: Mon Apr 16 2001 - 20:33:51 CDT


I'd just like to remind everyone about an important part of localization -
setlocale(). I've been chasing a few bugs in the tree caused by people not
using setlocale().

When should you use it? At least before and after every sprintf() that has a
numeric value. We've got to make sure that these formatted numbers work
right (our number parsing routines don't know what to do with 8,500in and
they shouldn't have to - 8.500in is the standard we're sticking to).

setlocale(LC_NUMERIC, "C"); // set locale to C
sprintf(buf, "%.4f", float_foo);
setlocale(LC_NUMERIC, ""); // reset locale

Get your FREE download of MSN Explorer at

This archive was generated by hypermail 2b25 : Mon Apr 16 2001 - 20:34:07 CDT