[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua interpreter and Lua files encoding
- From: Dirk Laurie <dpl@...>
- Date: Thu, 6 Jan 2011 12:59:20 +0200
On Thu, Jan 06, 2011 at 12:45:43PM +0200, Peter Odding wrote:
> > Anyway, is this only an implementation artifact? Or is something that
> > will last? In this latter case a mention in the reference manual could
> > be useful, since utf8 is very common nowadays and generating utf8 files
> > using Lua, _without specialized libraries_ and without the hassle of
> > encoding literals with escape sequence, is really a useful!
>
> The Lua 5.1 reference manual defines that "strings in Lua can contain
> any 8-bit value" but it doesn't guarantee the same for literal strings
> embedded in Lua source code.
Theorem: Given any literal string, it is possible to embed it into
Lua source code.
Proof: Suppose the string is N bytes long. Then it cannot contain
the substring '['..string.rep('-',N-1)..']'. That string
delimiter is therefore adequate for embedding the string. Q.E.D.
Dirk