in reply to Re: pack() v unpack() padding: bug or ???
in thread pack() v unpack() padding: bug or ???
I don’t see a problem here, either. The template Z2 specifies a 2-byte null-terminated string. Packing 'fr' of course requires 3 bytes, so the second character is thrown away and the packed result is f\0. Isn’t that what it’s supposed to do?
Can you think of a good use for that? Or even a not good use?
Mentioned in the docs is "Z A null-terminated (ASCIZ) string, will be null padded.". Wouldn't you expect it to grab the 2 characters and then add the null byte (if required)?
As is, it makes: pack 'Z1', $anything; a very complicated why of generating a null.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: pack() v unpack() padding: bug or ???
by roboticus (Chancellor) on Feb 16, 2015 at 16:43 UTC | |
by BrowserUk (Patriarch) on Feb 16, 2015 at 17:06 UTC |