[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua interpreter and Lua files encoding
- From: <jgiors@...>
- Date: Thu, 06 Jan 2011 08:02:55 -0700
> -------- Original Message --------
> Date: Thu, 6 Jan 2011 13:49:19 +0200
> From: Dirk Laurie <dpl@sun.ac.za>
> Subject: Re: Lua interpreter and Lua files encoding
> To: Lua mailing list <lua-l@lists.lua.org>
> Message-ID: <20110106114919.GA10105@rondloper>
> Content-Type: text/plain; charset=us-ascii
>
> On Thu, Jan 06, 2011 at 01:15:33PM +0200, Peter Odding wrote:
> > the Lua 5.1 reference manual seems to make no guarantees about
> > whether the lexer and parser preserve literal UTF-8 sequences
> > in string literals?
>
> They do, whether guaranteed or not.
>
> Lua 5.2.0 (alpha) Copyright (C) 1994-2010 Lua.org, PUC-Rio
> > b={}; for j=0,255 do b[j+1]=string.char(j) end; c=table.concat(b)
> > f=io.open('allbytes','w')
> > f:write('all=[['..c..']]; for i=1,#all do print(string.byte(all,i)) end')
> > f:close()
> > dofile('allbytes') -- prints out 0 to 255
>
<...snip...>
For the record, on Windows using Lua 5.1.2, I get this:
Lua 5.1.2 Copyright (C) 1994-2007 Lua.org, PUC-Rio
> b={}; for j=0,255 do b[j+1]=string.char(j) end; c=table.concat(b)
> f=io.open('allbytes','w')
> f:write('all=[['..c..']]; for i=1,#all do print(string.byte(all,i)) end')
> f:close()
> dofile('allbytes')
allbytes:3: unfinished long string near '<eof>'
stack traceback:
[C]: in function 'dofile'
stdin:1: in main chunk
[C]: ?
That error is the ASCII char 26 [hex 1A] that I mentioned in my previous
post. I assume this is a Windows issue (and that you're not running
Windows).
John Giors
Independent Programmer
Three Eyes Software
jgiors@ThreeEyesSoftware.com
http://ThreeEyesSoftware.com
P.S. If anyone is trying this test on other platforms, I recommend using
'wb' as the flag to io.open [instead of 'w']:
f=io.open('allbytes','wb')