[Qt-interest] Hi guys, fprintf problem

Constantin Makshin cmakshin at gmail.com
Wed Apr 7 23:53:12 CEST 2010


You may try to temporarily set the "LC_NUMERIC" parameter of the locale to "C" or "POSIX":

#include <locale.h>
...
char* oldLocale = setlocale(LC_NUMERIC, "C");
fprintf(...);
setlocale(LC_NUMERIC, oldLocale);

http://linux.die.net/man/3/fprintf
http://linux.die.net/man/3/setlocale

On Thu, 08 Apr 2010 01:37:28 +0400, Fabio Giovagnini <fabio.giovagnini at aurion-tech.com> wrote:
> Hi all,
> I know this is not the best place where to ask about fprintf function, but I
> do not know about glibc mailing list.
> So sorry but let me ask.
> I have Ubuntu 9.10 - Karmic Koala
> in Italian language.
> When I call
> fprintf(fd,"%.2f",floatval);
> into the file I find 0,84 supposed that floatval is 0.84; the function use the
> Italian comma decimal separator instead of the universal dot separator I
> supposed.
> This is for me a problem beacuse such these decimal values are into a comma
> separated file and with this notation my strtok based parser works wrongly.
>
> How can I force fprintf to use dot decimal separator?
> How caould to solve iun general this problem avoiding that fprintf detect teh
> LOCALE and customizes its behaviour correspondingly?
>
> Thanks in advance and sorry again.

-- 
Constantin Makshin



More information about the Qt-interest-old mailing list