views:

55

answers:

1

I am using NSNumberFormatter to create a currency formatted string. Everything works fine on most devices, but on some devices for example devices with Korean language, the $ sign shows up as a rectangle.

NSNumberFormatter *currencyStyle = [[NSNumberFormatter alloc] init];
[currencyStyle setFormatterBehavior:NSNumberFormatterBehavior10_4];
[currencyStyle setNumberStyle:NSNumberFormatterCurrencyStyle];
NSNumber *amount = [NSNumber numberWithInteger:moneyAmount];
NSString *amountString =  [NSString stringWithFormat:@"%@", [currencyStyle stringFromNumber:amount]];
[currencyStyle release];

Any way to fix this problem?

Rhanks

+1  A: 

Given your comment in the question, it sounds like you just want the $ currency symbol, regardless of whatever the defined currency symbol is for the user's current locale.

This is done using the -setCurrencySymbol: instance method of the NSNumberFormatter class. In your case, you could do the following:

[currencyStyle setCurrencySymbol:@"$"]; 
Sedate Alien
wow so it was actually trying to display Korean currency? Interesting, thanks
aryaxt