lua-users home
lua-l archive

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

> I am hunting a strange problem….
> When I output a number value, e.g. 42.0, it is normally output with a decimal point.
> On one particular platform, however, it is output with a comma, i.e. „42,0“.
> What controls that?  It happens during the conversion of a number to a a string, apparently.
> Setting LC_NUMERIC on the command line, e.g. like this, changes nothing:
> $ LC_NUMERIC=de lua -e ‘print(42.0)’
> (Neither does setting LANG, LC_ALL,  LANGUAGE)

That is controlled by the locale, as you suspected:

   [from the C standard]
   The decimal-point character is the character used by functions that
   convert floating-point numbers to or from character sequences to denote
   the beginning of the fractional part of such character sequences. 151)
   It is represented in the text and examples by a period, but may be
   changed by the setlocale function.

Probably a C program using 'printf' will do the same thing. You may
try to change the locale inside the program:

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

-- Roberto