[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Feature proposal: \x## notation in strings
- From: Peter Cawley <lua@...>
- Date: Mon, 9 Mar 2009 22:14:01 +0000
When hex is the accepted norm, it is alot easier to read hex than
decimal. For example, in the correct content, I would recognise \x90
and \xF4 as the x86 NOP and HLT instructions respectively. \144 and
\244 would be much less obvious in that context. Yes, they are
equivalent, but it is easier to write the code using the hex
constants, and easier to read the code again later when the constants
are in hex.
On Mon, Mar 9, 2009 at 10:06 PM, Alexander Gladysh <agladysh@gmail.com> wrote:
>> I'm using Lua a lot for embedded software, which tends to involve quite
>> a bit of working with low-level protocols, bits and binary data. One of
>> the things I'd personally like to see added in Lua to make my life a bit
>> easier is the C-like notation for 'binary' data in strings using
>> hexidecimal escape codes like \xNN.
>
> Probably this is a silly question, but is decimal notation not
> acceptable? I guess hexadecimals may be a bit more convenient in some
> cases, but they should be more or less equivalent.
>
> To quote manual:
>
> A character in a string can also be specified by its numerical value
> using the escape sequence \ddd, where ddd is a sequence
> of up to three decimal digits.
>
> Alexander.
>