Search code examples
iosformattingstring-formattingcurrencynsnumberformatter

NSNumberformatter displays "HUF" instead of "ft" when trying to format Hungarian currency


I'm trying format a number to Hungarian currency format. But for some reason it displays the 3 digit currency code instead of the forint symbol (ft) like so

10,00 HUF

It seems to work fine for other countries/currencies, for example British pounds is displayed

£10.00

Here is my code

let formatter = NSNumberFormatter()
formatter.numberStyle = .CurrencyStyle
formatter.currencyCode = "HUF"
formatter.locale = NSLocale(localeIdentifier: "hu_HU")
let formattedString = formatter.stringFromNumber(10)

Any idea why it behaves like this? Thanks in advance.


Solution

  • The problem seems to be that Hungary simply does not have a currency symbol other than HUF for iOS.

    formatter.internationalCurrencySymbol
    formatter.currencySymbol
    formatter.currencyCode
    

    all output

    "HUF"

    Even on the actual device by setting the region you will get that result:

    enter image description here enter image description here

    Therefore if your really, really want to get the symbol Ft you probably have to manually replace it.