本文介绍了Intl.NumberFormat()不显示比特币Ƀ符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Intl.NumberFormat不显示比特币符号.

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

我目前的解决方法

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

也许有更好(干净)的解决方案?

Is there maybe a better (clean) solution?

推荐答案

根据 bitcoin.it

因此正确的代码应为

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.

因此,我个人将使用XBT代码而不是BTC,根据ISO 4217,该代码完全无效,以防万一有一天它进入列表.

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.

这篇关于Intl.NumberFormat()不显示比特币Ƀ符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-26 16:54