Rushino Rushino - 7 months ago 9
Javascript Question

Why does the jQuery plugin Globalize reconize 9,999.99 in English local (en-CA) but not 9 999,99 in French local?

Why does Globalize

9,999.99
in English local (en-CA) but not
9 999,99
in French local (fr-CA). Is the space causing the problem in this scenario?

That happens when I call the numberParser method. NaN is returned if I enter
9 999,99
but that should be accepted since the formatter returns that.

Answer

Short answer thinking-out-of-the-box: Because current Globalize lacks a parser feature called "Loose Matching" https://github.com/jquery/globalize/issues/292.

Short specific answer: Because space and no-break space are two different characters. The "space" of the fr-CA grouping separator isn't a regular space (bytecode 32 = hex 20), but it's a no-break space (bytecode 160 = hex A0). Try "sanitizing" your input with input.replace( "\x20", "\xa0" ) before providing it to the parser as a workaround.

You can find detailed information at https://github.com/jquery/globalize/issues/288

I hope that helps :)