[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua interpreter and Lua files encoding
- From: David Manura <dm.lua@...>
- Date: Thu, 6 Jan 2011 00:10:32 -0500
On Wed, Jan 5, 2011 at 6:57 PM, Lorenzo Donati
> I know Lua can _store_ any octet sequence in a string. The doubt is with the
> interpreter executable: can it read and always parse a utf8 file with
> non-ASCII chars in some literals/comments?
According to , the lexer does not guarantee reliable preservation
of arbitrary octets in string literals, so you may need to encode
these octets with escape sequences. This is particularly due to ASCII
newlines ([\r\n]+) being normalized to '\n' (so that string literals
have the same meaning regardless of the newline encoding of the source
file). There's a lexer change in 5.2.0-alpha eliminating dependence
on locales , but that doesn't alter the newline normalization--see
the `inclinenumber` in `read_long_string` in llex.c.
This indeed in sometimes unfortunate. It means that Lua syntax is not
an ideal binary encoding format.
BTW,  had an interesting related request about whether its possible
to force memory alignment of string literals (and the answer is no).