我有此货币列表(来自https://openexchangerates.org)
{"AED":3.6729,"AFN":57.82755,"ALL":103.465001,"AMD":414.905,"ANG":1.787,"AOA":97.659999,"ARS":8.131418,"AUD":1.065732,"AWG":1.79,"AZN":0.7839,"BAM":1.445344,"BBD":2,"BDT":77.618221,"BGN":1.44457,"BHD":0.376997,"BIF":1553.3484,"BMD":1,"BND":1.25077,"BOB":6.90997,"BRL":2.2253,"BSD":1,"BTC":0.0016610606,"BTN":60.00055,"BWP":8.865137,"BYR":10173.333333,"BZD":1.99474,"CAD":1.087393,"CDF":926.513333,"CHF":0.899613,"CLF":0.0232,"CLP":556.539996,"CNY":6.210708,"COP":1880.283333,"CRC":556.712998,"CUP":0.9999,"CVE":81.0433,"CZK":20.26093,"DJF":178.380299,"DKK":5.507907,"DOP":43.27396,"DZD":79.3989,"EEK":11.68855,"EGP":7.150895,"ERN":14.952575,"ETB":19.57954,"EUR":0.738639,"FJD":1.825871,"FKP":0.589387,"GBP":0.589387,"GEL":1.76713,"GHS":3.09659,"GIP":0.589387,"GMD":39.6,"GNF":6961.666667,"GTQ":7.81589,"GYD":204.983752,"HKD":7.751421,"HNL":20.82528,"HRK":5.59851,"HTG":45.02112,"HUF":227.0625,"IDR":11812.583333,"ILS":3.458559,"INR":60.06054,"IQD":1177.766717,"IRR":25566,"ISK":114.098,"JEP":0.589387,"JMD":111.226,"JOD":0.70829,"JPY":101.8811,"KES":87.971741,"KGS":51.94185,"KHR":4041.333333,"KMF":363.47686,"KPW":900,"KRW":1019.49,"KWD":0.282206,"KYD":0.826662,"KZT":183.533001,"LAK":8052.216667,"LBP":1511.808333,"LKR":130.250001,"LRD":89.001533,"LSL":10.70319,"LTL":2.5504,"LVL":0.518188,"LYD":1.2312,"MAD":8.27075,"MDL":13.90944,"MGA":2410.6,"MKD":45.37356,"MMK":970.664,"MNT":1823.17334,"MOP":7.98312,"MRO":290.925,"MTL":0.683738,"MUR":30.34428,"MVR":15.45622,"MWK":394.397,"MXN":13.03642,"MYR":3.2241,"MZN":31.50475,"NAD":10.70799,"NGN":163.182999,"NIO":25.87152,"NOK":5.997004,"NPR":96.1525,"NZD":1.152707,"OMR":0.384962,"PAB":1,"PEN":2.7912,"PGK":2.448173,"PHP":43.90592,"PKR":98.54584,"PLN":3.057794,"PYG":4412.258268,"QAR":3.64089,"RON":3.24691,"RSD":85.24262,"RUB":34.58522,"RWF":682.30402,"SAR":3.75081,"SBD":7.2208,"SCR":12.25984,"SDG":5.694417,"SEK":6.645576,"SGD":1.25099,"SHP":0.589387,"SLL":4335,"SOS":936.00202,"SRD":3.308567,"STD":18107.5,"SVC":8.74892,"SYP":149.324999,"SZL":10.73045,"THB":32.35748,"TJS":4.923975,"TMT":2.85,"TND":1.66316,"TOP":1.854405,"TRY":2.135726,"TTD":6.43465,"TWD":30.02066,"TZS":1685.116667,"UAH":11.8597,"UGX":2569.95,"USD":1,"UYU":22.98366,"UZS":2305.953311,"VEF":6.292275,"VND":21206,"VUV":94.252501,"WST":2.298934,"XAF":484.799008,"XAG":0.05081723,"XAU":0.00078076,"XCD":2.70158,"XDR":0.649354,"XOF":485.16402,"XPF":88.20458,"YER":214.986999,"ZAR":10.71995,"ZMK":5252.024745,"ZMW":6.284713,"ZWL":322.355006}
并且知道我想为每种货币添加正确的货币符号和货币名称(以本地语言)。
有人知道这样的货币符号 list 吗?
$
'; €
'; £
'; 我不确定,每种货币都存在“HTML编码(数字)”符号吗?
(通常)可以将 native 货币名称存储在普通的JS对象中吗?
提前致谢。
最佳答案
openexchangerates.org支持的货币的名称(英语)可在http://openexchangerates.org/api/currencies.json-
{
"AED": "United Arab Emirates Dirham",
"AFN": "Afghan Afghani",
"ALL": "Albanian Lek",
/* ... */
"ZMK": "Zambian Kwacha (pre-2013)",
"ZMW": "Zambian Kwacha",
"ZWL": "Zimbabwean Dollar"
}
openexchangerates.org支持的货币的符号似乎不是由服务本身提供的。但是,可以从https://gist.github.com/Fluidbyte/2973986获得JSON文档,其中包含openexchangerates.com支持的大多数货币(168种货币中的124种)的符号(和其他信息)-
{
"USD": {
"symbol": "$",
"name": "US Dollar",
"symbol_native": "$",
"decimal_digits": 2,
"rounding": 0,
"code": "USD",
"name_plural": "US dollars"
},
/* ... */
"AFN": {
"symbol": "Af",
"name": "Afghan Afghani",
"symbol_native": "؋",
"decimal_digits": 0,
"rounding": 0,
"code": "AFN",
"name_plural": "Afghan Afghanis"
},
/* ... */
"ZMK": {
"symbol": "ZK",
"name": "Zambian Kwacha",
"symbol_native": "ZK",
"decimal_digits": 0,
"rounding": 0,
"code": "ZMK",
"name_plural": "Zambian kwachas"
}
}
如有必要,可以使用How to convert characters to HTML entities using plain JavaScript中的信息将本文档中的Unicode字符转换为HTML Entity Reference转义的字符串。
虽然显然可以在对象中存储任何字符串,但是以其唯一的本国语言表示货币的唯一名称的想法实际上并没有任何意义。
没有单一的母语,例如,用于:
关于native - 带有母语的货币符号和货币名称的货币列表,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24255834/