Intl.NumberFormat() does not show the Bitcoin Ƀ Symbol

冷暖自知 提交于 2019-12-11 01:14:52

问题


the Intl.NumberFormat does not show the bitcoin symbol.

CFORMAT_USD = new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'USD', minimumFractionDigits: 8 }); 
CFORMAT_BTC = new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'BTC', minimumFractionDigits: 8 }); 

console.log(CFORMAT_USD.format(1000));
// 1.000,00000000 $

console.log(CFORMAT_BTC.format(1000));  
// 1.000,00000000 BTC

My workaround at the moment

console.log(CFORMAT_BTC.format(1000).replace(/BTC/,'Ƀ'));
// 1.000,00000000 Ƀ

Is there maybe a better (clean) solution?


回答1:


According to bitcoin.it,

The ISO 4217 currency code for Bitcoin is XBT. However, at the moment it is an unofficial code according to the ISO 4217 standard.

So the correct code should be

Intl.NumberFormat('de-DE', { style: 'currency', currency: 'XBT' })

But since it has not made its way to this list, browsers didn't implement it yet.

So I would personally use the XBT code instead of BTC which is completely invalid according to ISO 4217, just in case it makes its way to the list some day.



来源:https://stackoverflow.com/questions/46019497/intl-numberformat-does-not-show-the-bitcoin-%c9%83-symbol

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!