lua-users home
lua-l archive

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


>> output:write (string.format ("bootstrap_image = [=[%s]=]", binary))

> It doesn't work at least due to newline mangling.

So I suppose your system is Windows.
On Windows, indeed, \r\n is turned into \n only because luaL_loadfile
opens Lua files in text mode.
This is a problem if the script contains binary data like with [[ ]].
But is that case, I am a bit surprised that you do not hit a problem
with character 26 (^Z) also.
Because Lua 5.1.4 does *not* escape that character with the "%q"
format, which is treated as an EOF marker when the file is read back
in text mode.
BTW Lua 5.2.0 has a better escaping scheme: all control characters are
turned to \nnn form, with the leading zeros only inserted when
necessary.