lua-users home
lua-l archive

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


On 11/2/12, Jim Studt <jim@studt.net> wrote:
> It would be nice to have a long literal that was actually literal
> for when you need precise values. e.g. you might want
> to embed a PNG, which has the offending pair in bytes 5 and 6,
> in a machine generated source file.

Use this "preprocessor" (%q format option rules!):

local png_file_content = 'A\0\r\nB'  -- any binary data here
local insert_this_text_into_your_lua_source =
   'local png = '..('%q'):format(png_file_content)..'\n'

:-)