lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> > Can't this be handled by setting a german locale?
> 
> 	In my last attempt to handle numerical input, I setted the locale to 
> pt_BR and voila, the parser stopped handling numeric constants :(

Yes, you have to be careful when parsing.  I meant something like:
	function mytonumber(x)
		os.setlocale("numeric","de_DE")
		x=tonumber(x)
		os.setlocale("numeric")
	end
 
> 	I wish Lua had it's own neutral locale

The Lua core cannot call setlocale because it is not ANSI C.
The alternative is to parse and convert numbers by hand, which is quite subtle
to get it right for floating-point.
--lhf