Skip to content

Instantly share code, notes, and snippets.

@rxaviers
Created May 6, 2016 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rxaviers/4e83090a826162138d3f0a520d5fa6db to your computer and use it in GitHub Desktop.
Save rxaviers/4e83090a826162138d3f0a520d5fa6db to your computer and use it in GitHub Desktop.

First install globalize and cldr-data:

npm install globalize cldr-data

Then, run node

node

And:

var Globalize = require( "globalize" );
Globalize.load( require( "cldr-data" ).entireSupplemental() );
Globalize.load( require( "cldr-data" ).entireMainFor( "en-CA" ));

Globalize( "fr-CA" ).parseNumber( "9 999,99" );
// > NaN

Globalize( "fr-CA" ).parseNumber( "9 999,99".replace( "\x20", "\xa0" ) );
// > 9999.99

Globalize( "fr-CA" ).parseNumber( "9 999,99".replace( " ", "" ) );
// > 9999.99
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment