Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i get currency symbols from currency code in iphone?

I have get currency code (Eg: USD, EUR, INR) from webservice response. I need to show the currency symbols for the corresponding currency code. If the currency code is USD, i need to show $, if the currency code is EUR i need to show €. How can i do this? Please suggest any idea or sample code to do this. Please help me. Thanks in advance.

like image 332
Yuvaraj.M Avatar asked Jan 03 '12 13:01

Yuvaraj.M


People also ask

How do you make the currency symbol?

public final Map<String, String> CURRENCIES= new HashMap<String, String>(){ { put("EUR","€"); put("USD","$"); ... } }; Then, you can get the symbol by using Locale, like this. Show activity on this post. You can simply use this code to get the currency symbol and different currency formats.

How do I get the currency symbol from locale?

The getSymbol() method is used to get the symbol of a given currency for the default DISPLAY locale. For example, for the US Dollar, the symbol is "$" if the default locale is the US, while for other locales it may be "US$". If no symbol can be determined, the ISO 4217 currency code is returned.

How do I get the baht symbol on my iPhone?

You get all the currency symbols except the Baht for free on the US keyboard. Press and hold the $ symbol and you'll see all the alternates. To get the Baht symbol - add the thai keyboard and the Baht symbol will be added to the US keyboard. You don't need to switch to that keyboard - just add it.


1 Answers

This code works charm in my project. I will share this to you all.

NSString *currencyCode = @"EUR";     NSLocale *locale = [[[NSLocale alloc] initWithLocaleIdentifier:currencyCode] autorelease];     NSString *currencySymbol = [NSString stringWithFormat:@"%@",[locale displayNameForKey:NSLocaleCurrencySymbol value:currencyCode]];     NSLog(@"Currency Symbol : %@", currencySymbol); 

Thanks.

like image 131
Yuvaraj.M Avatar answered Sep 28 '22 03:09

Yuvaraj.M