I'm having an issue with Intl.NumberFormat
using a Swedish locale. If you run:
new Intl.NumberFormat('en-uk', {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
}).format(-2);
It returns -2.00
with minus sign U+002D
, but if you run:
new Intl.NumberFormat('sv-se', {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
}).format(-2);
It returns −2,00
with minus sign U+2212
.
This messes up my validation functions because JS cannot do math operations with the U+2212
sign.
10 − 2
Uncaught SyntaxError: Invalid or unexpected token
Is there a way to set the minus character for Intl.NumberFormat
? Or is there a way around this without some ugly hack? Thanks!