Hi Stef, Fred,
Here's a little test I did on Mac OS 10.7, after setting the number formatting
locale to French in System Preferences:
#import <Foundation/Foundation.h>
#import <CoreFoundation/CoreFoundation.h>
int main (int argc, const char * argv[])
{
@autoreleasepool {
NSLog(@"%@", CFStringCreateWithFormat(NULL, NULL, CFSTR("%f"),
4.34f));
NSLog(@"%@", [NSString stringWithFormat: @"%f", 4.34f]);
NSLog(@"%@", [NSString localizedStringWithFormat: @"%f",
4.34f]);
}
return 0;
}
and the result:
2012-07-18 22:32:10.981 testtool[58336:707] 4.340000
2012-07-18 22:32:10.985 testtool[58336:707] 4.340000
2012-07-18 22:32:10.991 testtool[58336:707] 4,340000
So it seems CFStringCreateWithFormat behaves the same as -[NSString
stringWithFormat:], which is never affected by the current locale.
I had a look at CFStringFormat.c. I think what you want to change is the locale
param passed to unum_open; ICU interprets null as the "ICU default locale",
which is a locale that depends on the user's setting in their operating system.
I /think/ you want to use "en_US_POSIX" instead of null (see
http://userguide.icu-project.org/locale , there are also various shortcuts like
"" or "C" which map to "en_US_POSIX".)
Cheers,
Eric
On 2012-07-18, at 20:56, Stefan Bidi wrote:
> On Wed, Jul 18, 2012 at 3:39 PM, Fred Kiefer <[email protected]> wrote:
>> For me (OpenSuse 64bit AMD) the only failing test is this one:
>>
>> Failed test: format.m:28 ... Float/Doubles are formatted correctly
>> expected 5.500000 5.5 3.000000e-06, but got 5,500000 5,5 3,000000e-06
>>
>> This definitely is a problem of the locale, you should have a look at the
>> base test in NSNumberFormatter/basic10_4.m on how to ensure a specific
>> locale for the test.
>
> Would this be correct, though? According to the Apple documentation
> the formatOptions parameter (which is an "unimplemented feature") is
> what specifies the decimal separator, etc. I think the problem here
> is that I use unum_formatDouble() instead of something else.
>
> I don't have a mac, so I can't test how floats/doubles are formatted
> when the locale specifies a ',' for decimal separator.
>
>>
>> Fred
>>
>
> _______________________________________________
> Discuss-gnustep mailing list
> [email protected]
> https://lists.gnu.org/mailman/listinfo/discuss-gnustep
_______________________________________________
Discuss-gnustep mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/discuss-gnustep