[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Feature proposal: \x## notation in strings
- From: Nick Gammon <nick@...>
- Date: Thu, 26 Mar 2009 11:32:29 +1100
I know it is almost 2 weeks later, but I would also like to support
the \x## notation.
It is worth noting that there would be backwards incompatibilities
with any code that currently has stuff like "\x22" in it (which
current renders as "x22").
At present, it is tedious if you read (for example) somewhere about a
telnet IAC sequence (like ff f0 ff fb 56 ff), and want to incorporate
it into your Lua code. If Lua supported the \xHH sequence, a simple
find-and-replace of the spaces would fix them up into a usable string.
However now you need to translate each one into decimal.
Unlike some other suggestions for changes, this suggestion does not
cause run-time code bloat, or extra execution time. Compile time
increase would be marginal at best. And the extra code in Lua would be
minimal.
By the way, with reference to the Principle Of Least Surprise, the
sequence \012 in C is the number 0x0A whereas in Lua is is 0x0C.
Considering how closely the string escape sequences mimic C's (and the
reference in the manual to C-like escape sequences), that is a bit of
a surprise. :)
- Nick