Re: pack it in

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Thu, January 24, 2008 6:13 pm, Jochem Maas wrote:
> Richard Lynch schreef:
>> On Thu, January 24, 2008 5:20 pm, Jochem Maas wrote:
>>> someone asked about checksum values in another thread, I believe
>>> he got his answer no thanks to me. but whilst I was trying to help
>>> I got stuck playing with pack/unpack.
>>>
>>> so now I have the broadbrush question of what would one use
>>> pack/unpack for? can anyone point at some realworld examples/code
>>> that
>>> might help me broaden my horizons?
>>
>> Reading a "binary" file with various bytes/bits that need to get
>> converted to integers for you to do something useful with them.
>
> ok. that's where my brain goes to mush - all strings in php (for now)
> are binary ... what's the difference between the binary strings
> in php and such found in these 'binary files' that they need to be
> packed/unpacked?
>
> sorry if I'm sounding retarded ... I probably am :-/

If you read a binary file with a bunch of (integer) values in it, you
get a big long string that looks like symbol-soup when you print it,
because it's a big fit binary string.

You'd like to break that up into, say, the actual integers and bytes
that were intended.

The bytes that were intended may or may not be in big-endian or
little-endian format, for that matter...

Anyway, unpack is one way to tear the string apart into the formatted
data.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux