Search code examples
javascriptgoogle-chromeecmascript-6localecurrency

Why does de-DE locale on Chrome use char code 160 instead of 32?


const EUR = new Intl.NumberFormat("de-DE", { style: "currency", currency: "EUR" })
const a = EUR.format(1)
console.log(a)
//"1,00 €"
console.log(a.charCodeAt(4))
//160

Why does de-DE locale on Chrome use char code 160 instead of 32?


Solution

  • Unicode 160 is a NO-BREAK SPACE, which makes sense, because you absolutely don't want the currency symbol to be alone in the next line if there isn't enough space. The currency symbol is part of the price and should stay near it.