Hello
in my App I have a text label displaying the number 200,000 with the thousand separator ‘,’.
now when I read that by using tonumber(“200,000”). it causes an error due to the comma.
Now to fix this I can use, string.gsub(“200,000”, ‘,’, ‘’).
which will give me 200000. Which is fine as long as my numbers use ‘,’ as the thousand separator.
But what if my iPad or Tablet is set in a region that uses ‘.’ as the thousand separator, like Europe, is there a system parameter or global parameter that I can read something like in other languages number.thousandseparator = ‘,’ so I can detect if I need to switch out the ‘,’ or the ‘.’ in the large (thousand plus) number?
So in region like US or UK I can use string.gsub(“200,000”, ‘,’, ‘’)
but in Europe I will need to use string.gsub(“200.000”, ‘.’, ‘’)
I need some like os.setlocale() or os.getlocale() to tell me the locale thousand separator so I can use a simple variable to hold the locale thousand separator character.
str = “200,000”. or it could be “200.000” if I am in Europe.
localeSep = “,” or “.” which I need to get from the system settings But how?
string.gsub(str, localeSep, ‘’)
regards
Bruce