Search code examples
javascriptlocalizationcldr

Parse twitter-cldr-js formatted number back into integer or float?


Is there any easy way to do reverse of:

// include twitter_cldr/es.js
var fmt = new TwitterCldr.DecimalFormatter();
fmt.format(1337); // "1.337"

i.e. parse "1.337" back to integer with value of 1337?

The solution should work for any twitter-cldr-js supported locale.

I am not looking for parseInt / parseFloat, as it does not handle all possible locales.


Solution

  • After two days of trial & error I've found it impossible to do this using twitter-cldr-js and turned to Globalize instead, which does the job very neatly.