http://qs1969.pair.com?node_id=1116870


in reply to pack() v unpack() padding: bug or ???

This pack thing is just a pain. unpack is not the exact opposite, no.
The "a", "A", and "Z" types gobble just one value, but pack it as a string of length count, padding with nulls or spaces as needed. When unpacking, "A" strips trailing whitespace and nulls, "Z" strips everything after the first null, and "a" returns data with no stripping at all.
pack

Replies are listed 'Best First'.
Re^2: pack() v unpack() padding: bug or ??? (strip)
by tye (Sage) on Feb 16, 2015 at 19:23 UTC

    Another way to look at it is: unpack() does the opposite of pack() and the opposite of padding is stripping. (No, I'm not claiming that unpack() always does the exact opposite of pack().)

    - tye