【问题标题】:Intl.NumberFormat() does not show the Bitcoin Ƀ SymbolIntl.NumberFormat() 不显示比特币Ƀ符号
【发布时间】:2018-02-11 15:44:03
【问题描述】:

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

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 Ƀ

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

【问题讨论】:

    标签: javascript number-formatting bitcoin


    【解决方案1】:

    根据bitcoin.it

    比特币的 ISO 4217 货币代码是 XBT。但是,目前它是符合 ISO 4217 标准的非官方代码。

    所以正确的代码应该是

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

    但由于它还没有进入this list,浏览器还没有实现它。

    所以我个人会使用 XBT 代码而不是 BTC,根据 ISO 4217,它是完全无效的,以防万一有一天它进入列表。

    【讨论】:

      猜你喜欢
      • 2019-02-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-16
      • 1970-01-01
      • 2015-07-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多