lua-users home
lua-l archive

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


Quoth Dirk Laurie <dpl@sun.ac.za>, on 2011-02-11 12:14:56 +0200:
> At present I can read in a file containing student grades, with 
> lines like
>     1.5     3.8  9.1    10.0

Something nobody's mentioned yet is that Lua numeric/string coercion
in Lua is naturally dependent on the C standard library---which means
it can be affected by the C locale!  Lua doesn't call setlocale() by
default, but if any other part of your program does...

  $ LC_ALL=fr_FR.UTF-8 lua
  Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
  > a = '1.3'; b = 1.3
  > =a+b
  2.6
  > os.setlocale('')
  > =a+b
  stdin:1: attempt to perform arithmetic on global 'a' (a string value)
  stack traceback:
          stdin:1: in main chunk
          [C]: ?
  > =b
  1,3

   ---> Drake Wilson