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?
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.