lua-users home
lua-l archive

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


> You can use '\0', but there is a problem if the next element is a digit.
> "\0007" is '\0' followed by '7', but "\07" is something different. You
> can avoid this problem with a frontier pattern:
>
>  output:write ((string.gsub (string.format ("bootstrap_image = %q",
>  binary), "\\000%f[%D]", "\0")))

You meant of course this (2 backslashes before last zero character):
output:write ((string.gsub (string.format ("bootstrap_image = %q",
binary), "\\000%f[%D]", "\\0")))

Thanks for the tip, anyway))
But I meant what I wrote: putting zero byte like string.byte (0), not
putting backslash and zero character.
Again, it works fine for me but will it work everywhere? I couldn't
find an answer in manual or the list.

> (Anyway note that, as Rapin pointed out, there may be more efficient
> ways to store your data.)

How exactly?
Manual says:
`Literals in this bracketed form can run for several lines,
do not interpret any escape sequences, and ignore long brackets of any
other level.`
And that means, I can't encode newlines unchanged ("\r\n" turns to "\n").