lua-users home
lua-l archive

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



On Jan 15, 2004, at 19:00, Stoil Todorov wrote:

Tank You, guys
But I don't want to change all local settings:-(
I want to change only digital sign - I want to be sure
 that digital sign will be point during executing Lua
code...
Is it possible?

I think so:

os.setlocale("C", "numeric")

or you can do it from C:

setlocale(LC_NUMERIC, "C")

Technically this also changes some other aspects of number formatting, such as the thousands grouping character. See the reference for the C function localeconv. Standard C does not use the other aspects of number formatting, but your host application or the operating system might.

Note that os.setlocale can be used to retrieve the current locale settings as well. So if you want to switch between the current locale and C do something like this:

numeric_locale = os.setlocale(nil, 'numeric')

os.setlocale('pl_PL', 'numeric')

-- do stuff using comma as the decimal point (at least on Mac OS X 10.3).

-- restore the old locale setting

os.setlocale(numeric_locale, 'numeric')

I have to say that this feature is not well documented, but obvious enough if you know the C side of things.

David Jones