request for future versions of lua

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

request for future versions of lua

Norman Ramsey-3
I would like to be able to put binary data in Lua string literals.
Lua handles this fine, but the resulting files are hard to print
to the terminal becuase of all the non-printing characters.  If
Lua were to implement an escape sequence \xNN, where NN are two
hexadecimal digits, I could avoid this problem.  Having
format('%q', ...) implement the same dodge would be even better,
but I can live without that if I have to.

If the Lua Masters might be interested in this, I am willing
to add the code to lex.c and strlib.c.

Norman

Reply | Threaded
Open this post in threaded view
|

Re: request for future versions of lua

Luiz Henrique de Figueiredo
>From [hidden email] Mon Jun 29 01:07:47 1998
>
>I would like to be able to put binary data in Lua string literals.

This is already implemented in 3.1 (but not in 3.1alpha).

The new manual is available at
	http://www.tecgraf.puc-rio.br/lua/manual/new/

>Lua handles this fine, but the resulting files are hard to print
>to the terminal becuase of all the non-printing characters.  If
>Lua were to implement an escape sequence \xNN, where NN are two
>hexadecimal digits, I could avoid this problem.

The escape sequences are in decimal, however.

>Having
>format('%q', ...) implement the same dodge would be even better,
>but I can live without that if I have to.

That's a good idea. But I don't know whether we can put into 3.1.
Like Roberto said, it is frozen now.

In case we don't add it to 3.1, you can always use gsub for the job:

gsub(s,"([0-31,127-255])",
	function (x)
		return format("\\%03d",strbyte(x))
	end

--lhf