How can I check if which side the currency symbol is at? For example, in the United States, the symbol would be like this: "$56.58
", but in France it would be like this: "56.58€
". So how would I be able to detect if it's on the right or left side?
NSNumberFormatter *currencyFormatter = [[[NSNumberFormatter alloc] init] autorelease];
[currencyFormatter setLocale:[NSLocale currentLocale]];
If you just want to format a number as currency, set the formatter's
numberStyle
toNSNumberFormatterCurrencyStyle
and then use itsstringFromNumber:
method.If, for some reason, you really want to know the position of the currency symbol in the format for the formatter's locale, you can ask the formatter for its
positiveFormat
and look for the character¤
(U+00A4 CURRENCY SIGN).Result:
Note that in the
fa-IR
case, the symbol is not the first or last character in the format string. The first character (at index zero) is invisible. It's U+200E LEFT-TO-RIGHT MARK.