不要从numbernormatter获取货币符号
以下代码的输出为: ars 59.00 。为什么没有打印符号?
let formatter = NumberFormatter()
formatter.currencyCode = "ARS"
formatter.numberStyle = .currency
print(formatter.string(from: NSNumber(value: 59.00)) ?? "na")
The output of following Code is: ARS 59.00. Why is there no symbol printed?
let formatter = NumberFormatter()
formatter.currencyCode = "ARS"
formatter.numberStyle = .currency
print(formatter.string(from: NSNumber(value: 59.00)) ?? "na")
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
强迫自定义语言环境
显示货币,您需要为当前语言环境显示货币符号($,€,¥,£)。
NumberFormatter将显示正确的符号,并且您可能没有意识到的格式与您的使用符号有很大不同。 审视
不同的国家使用不同的小数分隔符和 //supereasyapps.com/blog/2016/2/8/how-to-use-use-nsnumberformatter-in-swift-to-make-currency-currency-numbers-easy-to-read-to-Read“ rel =“ nofollow noreferrer”>如何使用Swift中的NumberFormatter(NSnumberFormatter)使货币数字易于阅读,
因此在您的情况下是:
Forcing a Custom Locale
To display currency, you will need to show the currency symbol ($, €, ¥, £) for the current locale.
NumberFormatter will show the correct symbol, and the formatting that you might not realize is very different from what you're used to. Different countries use different decimal separators and grouping separators—take a look!
See: How to Use NumberFormatter (NSNumberFormatter) in Swift to Make Currency Numbers Easy to Read
So in your case it would be:
尝试以下尝试:
在此处检查本地标识符: https://gist.github.com/jacobbubu/jacobbubu/1836273
Try this:
check the local identifier here: https://gist.github.com/jacobbubu/1836273