|
On 10/03/2009 15:51, David Given wrote:
Actually, rather than octal, I was expecting \099 to become an embedded NUL followed by '99', as the docs specifically say:Strings in Lua can contain any 8-bit value, including embedded zeros, which can be specified as '\0'.So I'd argue that this *still* contains a nasty surprise, just not the one I was expecting. (I see now that \0 is just a subset of \ddd, and not a special case. Perhaps a clarification would be useful?)
I am not surprised, but that's the dark side of decimal escapes: the fact they can have 1 to 3 digits, without end delimiter. An old problem of embedding variable width Ascii information with special meaning inside plain Ascii string.
Somehow, that's another argument for hex escapes: beside the fact we are familiar with them, and are handy, they have the advantage of being of fixed width, so there is no ambiguity: \x0099 will do what you expect.
I vote for the simple two hex digit escape (no Unicode, as it would really bloat (unlike the simple version) and has many variants (UTF-8 and 16 at least) -- and you can do any form by assembling bytes anyway).
-- Philippe Lhoste -- (near) Paris -- France -- http://Phi.Lho.free.fr -- -- -- -- -- -- -- -- -- -- -- -- -- --