Kero van Gelder
4/8/2006 12:26:00 PM
On 2006-03-30, baumanj@gmail.com <baumanj@gmail.com> wrote:
> Perhaps this should be a new subject like "adding formats for
> pack/unpack". I gave this a bit of thought, and there are quite a few
> formats that seem to be missing. I would naturally assume that there
> should be support for each combination of
>
> {unsigned, signed} x {native, network, little-endian} x {short, int,
> long}
8/16/32/64 bits int [in C, native short can be 16 bits, need not be]
16(?)/32/64 bits float [signedness irrelevant]
ascii chars, other string encodings(?) [signedness and endianness irrelevant?]
Then there are Endian formats that you wouldn't create in your nightmares.
However, is there any point for "native short" to allow for different
endianness? It's no longer the native short...
A problem is that single characters do not scale, you'll run out of the
alphabet eventually.
clear(?) but absolutely-not-concise suggestion:
"stuf".unpack(Integer, :32bits, :signed, :obscure_endianness)
file.read(Native::sizeof(:int) * 3).unpack(:int, 3)
Perhaps you can change those modifiers to something like "-32oI" and "i3"
but then I fear backwards compatibility issues.
Bye,
Kero.