NSNumberFormatter in 10_4 mode and zero symbols
NSNumberFormatter in 10_4 mode and zero symbols
- Subject: NSNumberFormatter in 10_4 mode and zero symbols
- From: Frank Illenberger <email@hidden>
- Date: Thu, 20 Oct 2005 09:48:32 +0200
Hi,
I am making use of the new features of NSNumberFormatter in its 10_4
mode but I am having problems using the zeroSymbol. As there is
literally no documentation, I am assuming that "zeroSymbol" means the
string the formatter should present if the number to be formatted is
a zero.
This normally works perfectly. But if I am formatting currencies in
which the currency symbol is a prefix to the number, the formatter
behaves really strange:
This is the example code I am using:
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
[formatter setNumberStyle:NSNumberFormatterCurrencyStyle];
[formatter setCurrencySymbol:@"$"];
[formatter setPositiveFormat:[NSString stringWithFormat:@"%
C#,##0.00", 0x00A4]];
NSLog(@"Zero: %@", [formatter stringFromNumber:[NSNumber
numberWithFloat:0.0]]);
NSLog(@"Fourty-Two: %@", [formatter stringFromNumber:[NSNumber
numberWithFloat:42.0]]);
[formatter setZeroSymbol:@"$0"];
NSLog(@"Zero: %@", [formatter stringFromNumber:[NSNumber
numberWithFloat:0.0]]);
NSLog(@"Fourty-Two: %@", [formatter stringFromNumber:[NSNumber
numberWithFloat:42.0]]);
[formatter release];
[pool release];
return 0;
}
Which produces the following output:
Zero: 0
Fourty-Two: $42,00
Zero: $0
Fourty-Two: $(&,$$
Does anybody have any idea what is going on here?
Cheers
Frank
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden