lua-users home
lua-l archive

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


>From nr@cs.virginia.edu 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