The online racing simulator
Making a Better Pack & Unpack function for PHP, Format & Unformat.
(2 posts, started )
Making a Better Pack & Unpack function for PHP, Format & Unformat.
String NUL Pad a A Space Pad
Hex Str Low Nibble h H High Nibble
Null Byte x X Back Up

bit 1bit t
nibble 4bit n N u4bit
byte 8bit b B u8bit
short 16bit s S u16bit
long 32bit l L u32bit
float 32float f F 32decimal
double 64double d D 64decimal
quad 128quad q Q 128decimal

Struct {}
Backrefrence [Varable]
Inrefernce ()

So MCI packets unformat string would look like this would look like this.

bSize/bType/bReqI/bNumC/[NumC]Info{SNode/sLap/bPLID/bPosition/bInfo(tBlue/tYellow/t3/tLag/tFirst/tLast)/bSp3/lX/lY/lZ/sSpeed/sDirection/sHeading/sAngVel}

The only limitation is that back references, and in references would have to be same level only to avoid ambiguity. If I knew C++ better, and I had the PHP SDK, I would make this function and add it to PHP myself. I think this it a worth wild project. I also think that JavaScript should have these functions as well with the upcoming WebSocket support for binary data.
I was thinking about Endianness using + and - before the datatype. If you had no symbol it would use the native system endianness. I've also slightly expanded it scope.

Null Byte x X Back Up

String NUL Pad a A NUL Pad Trim
String Space Pad z Z Space Pad Trim
String UTF-8 Char v V UTF-8 Char Trim
String UTF-16 Char w W UTF-16 Char Trim

Hex Str Low Nyble y Y High Nyble

bit 1bit i
nibble 4bit n N u4bit
byte 8bit b B u8bit
short 16bit s S u16bit
long 32bit l L u32bit
double 64bit d D u64bit
quad 128bit q Q u128bit

float 32float f F 32decimal
float 64float o O 64decimal
float 128float t T 128decimal

Endianness
(No Symbol) - System Native
+ - Big Endianness
- - Little Endianness

I want to make this into the SplStruct class.

Making a Better Pack & Unpack function for PHP, Format & Unformat.
(2 posts, started )
FGED GREDG RDFGDR GSFDG