各国的“货币小数位数宽度”在 iPhone-SDK 中
我读到了有关 NSLocaleCurrencySymbol 的内容,但是我在哪里可以找到用于确定国家货币中使用的“小数位数”的变量?
IE 在美国,常见的是用两位小数书写的美元金额: $1.23
那么许多其他国家呢?
I read about NSLocaleCurrencySymbol, but where would I find the variable used to determine the "number of decimal places" used in a country's currency?
I.E. In the USA, it's common to see dollar amounts written with 2 decimal places: $1.23
What about many other countries?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
还有许多其他国家/地区显示不同的小数位数。 2 是大多数,0(其货币中没有美分,例如日本)是最大的少数,3 仅在少数中使用。据我所知,没有其他号码了。当报价时,通常会使用更多的小数点。我所知道的带有 0 和 3 的货币如下所示。
ISO 货币代码可在以下位置找到:
http://www.iso .org/iso/support/currency_codes_list-1.htmhttp://en .wikipedia.org/wiki/ISO_4217 或 http: //www.currency-iso.org/en/home/tables/table-a1.html。There are a number of other countries that display a different number of decimal places. 2 is the majority, 0 (no cents in their currency, e.g., Japan) is the largest minority, 3 is used in just a few. No other number that I know off. When exchange rates are quoted, more decimals are typically used. The currencies with 0 and 3 that I'm aware of are shown below.
The ISO currency codes can be found at:
http://www.iso.org/iso/support/currency_codes_list-1.htmhttp://en.wikipedia.org/wiki/ISO_4217 or http://www.currency-iso.org/en/home/tables/table-a1.html.在 iOS 6(可能更早)中,您可以从设置为正确区域设置的 NSNumberFormatter 的 minimumFractionDigits 属性中找出货币小数点后的位数:
请注意,您必须调用 [formatter setNumberStyle:NSNumberFormatterCurrencyStyle] 在 minimumFractionDigits 属性填充正确的值之前(我只花了半个小时就搞定了!)
In iOS 6 (and possibly earlier) you can find out the number of digits after the decimal place of a currency from the minimumFractionDigits property of an NSNumberFormatter set to the correct locale:
Note that you must call [formatter setNumberStyle:NSNumberFormatterCurrencyStyle] before the minimumFractionDigits property is populated with the correct value (that one only took me half an hour to work out!)
http://cldr.unicode.org/
这里有很多你正在寻找的东西。
http://cldr.unicode.org/
This has much of what you're looking for.
根据 Robert Atkins 的回答,可以在 .NET 上做同样的事情。要测试此代码,请创建一个控制台应用程序项目并将 Program.cs 替换为:
Bulding on Robert Atkins' answer, it is possible to do the same thing on .NET. To test this code, create a Console App project and replace Program.cs with this: