discuss-gnustep
[Top][All Lists]
Advanced

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

Re: locale dependent printf


From: Richard Frith-Macdonald
Subject: Re: locale dependent printf
Date: Sat, 28 Apr 2001 06:56:59 +0100

On Thursday, April 26, 2001, at 03:09 PM, Michael Scheibler wrote:

Richard Frith-Macdonald <address@hidden> wrote:


On Thursday, April 26, 2001, at 01:05 PM, Michael Scheibler wrote:


I am using printf to print a float value and I am getting different
results
in an application using GNUstep/ObjC and Java (not JIGS) (result: 9,5)
compared to a dummy C application which only prints a float (result:
9.5).
Is it possible that GNUstep sets some locale information which affects
printf's behaviour?

GNUstep sets the locale from the standard environment variables using
setlocale(LC_ALL, "").  See the setlocale() man page for details on
what environment variables are used.


Then I think I have found another bug, because I don't have any possibility
to get a float number locale independent. I tried with [NSString
stringWithFormat: "%f", floatValue] and with [[NSNumber numberWithFloat:
floatValue] stringValue].
Even saving this NSNumber instance into a dictionary and writing it to a
file failed. I always get 9,5 instead of 9.5.

I have hacked the GSFormat code to use the NSDecimalSeparator from the locale
to rewrite the output from sprintf of floats.
This should mean that, by setting NSDecimalSeparator in your defaults, you can control how localizedStringWithFormat, and initWithFormat:locale:... methods
work, in order to override the effect of your environment variables.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]