简体   繁体   中英

NumberFormatter not using the correct decimal separator for “fr_CH” locale

I'm just wondering if I missed something or it is some kind of bug in the NumberFormatter

let numberFormatter = NumberFormatter()
numberFormatter.numberStyle = .currency
numberFormatter.locale = Locale(identifier: "fr_CH")
print(numberFormatter.decimalSeparator)
print(numberFormatter.string(from: 123.45))

The output is:

Optional(",")
123.45 CHF // I would expect `123,45 CHF`

So far, I've only found this problem for this particular region. Can anyone recreate this?

Change

print(numberFormatter.decimalSeparator)

To

print(numberFormatter.currencyDecimalSeparator)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM