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, ""))
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.
SlimerDude Mon 3 Feb 2020
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:
but the best I'm aware of is:
brian Mon 3 Feb 2020
That is true, there is no fromLocale on Int or Float - currently just what you suggest to replace those special chars