I have lua program, that loads data from string. I need to convert those data to double, using tonumber. Problem is, that under cygwin in Windows 7, I got nil
, if number contains .
insetad of ,
. How to solve this ?
n = tonumber("7.5") -> gives nil
n = tonumber("7,5") -> gives 7.5
Try this:
old = os.setlocale("C")
n = tonumber("7.5")
os.setlocale(old)