lua-users home
lua-l archive

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


Hi,

manel wrote:
> Why the interactive lua works differently than the non-interactive one
> (in this subject)?

The readline library (used for reading from the interactive
prompt) initializes the locale from the environment variables as
a side effect. This doesn't happen in non-interactive mode.

> What is the solution?

$ lua -e 'í=1; print(í)'
lua: (command line):1: unexpected symbol near 'í'

$ export LUA_INIT='os.setlocale(os.getenv("LC_CTYPE"), "ctype")'
$ lua -e 'í=1; print(í)'
1

Or put this line into a script which is loaded first. This script
must not contain any non-ASCII identifiers because it's parsed
completely before it's run. But any subsequently parsed files
(dofile, loadfile, require etc.) are allowed to contain NLS
characters in identifiers.

Bye,
     Mike