#2783 Parsing numbers from different locales

SlimerDude Mon 3 Feb

This is probably an oversight on my behalf, but how do you parse a number (Float or Int) from a locale in Fantom?

Specifically, how do I parse a number with a thousand separator without mistaking it for a decimal separator?

I would have liked something like:

str := "1,000"
int := Int.fromLocale(str)

but the best I'm aware of is:

str := "1,000"
int := Int.fromStr(str.replace(Num.localeGrouping, ""))

brian Mon 3 Feb

That is true, there is no fromLocale on Int or Float - currently just what you suggest to replace those special chars

Login or Signup to reply.