fallenpegasus: amazon (Default)
[personal profile] fallenpegasus
So I have a string that has a binary data structure in it, and I want to use Perl's unpack() on it

The binary structure is a 32bit int, followed by N 8 byte chunks. And I don't have quadwords in this build of Perl, so I cant treat them as 64bit ints.

And the following unpack string doesnt work: "L(a8)*".

What would the correct unpack string be?

A shot in the semi-dark...

Date: 2008-11-21 09:06 pm (UTC)
From: [identity profile] tcepsa.livejournal.com
What about "L(c8)*" ?

Reasoning: Looks like "a" signifies a null-terminated character string, so your expression would be "A long, followed by some number of groups of 8 null-terminated strings at a time". At the same time, c signifies a signed char (it doesn't sound like signed-ness makes a difference in this particular case), which is a byte, and you want an unknown number of groups of 8 bytes at a time.

Edited to add reasoning and fix the signed-ness of what c actually represents.
Edited Date: 2008-11-21 09:10 pm (UTC)

Date: 2008-11-21 09:15 pm (UTC)
From: [identity profile] elfs.livejournal.com
Assuming your string is in $c:

use Encode;
$l = (length(Encode::encode_utf8($c)) - 4) / 8;
@f = unpack('L' . ('(a8)' x $l), $c);
print "@f\n";

The Encode forces length to treat your strings as a collection of 8-bit bytes. The 'x' operator (yes, that's really a lower-case x, by the uncaring stars I hate Perl) in a string context causes multiplication of the string entity.

loans no fax online 12824

Date: 2013-07-07 02:39 am (UTC)
From: (Anonymous)
payday no fax (http://paydaynewyorkhere.com/#lvhob) - payday cash advance new york (http://paydaynewyorkhere.com/#ldkbv) , http://paydaynewyorkhere.com/#mcuoe loans no fax

achat cialis 411

Date: 2013-07-13 06:13 pm (UTC)
From: (Anonymous)
cialis en ligne sans ordonnance (http://achetercialisici.com/#onhgj) - acheter cialis (http://achetercialisici.com/#tiyns) , http://achetercialisici.com/#rhvug acheter cialis 20 mg

acheter cialis 10 mg 15205

Date: 2013-07-13 06:26 pm (UTC)
From: (Anonymous)
acheter cialis online (http://achetercialisici.com/#rmrby) - acheter cialis pas cher (http://achetercialisici.com/#wlhjb) , http://achetercialisici.com/#pingq acheter cialis 20 mg


fallenpegasus: amazon (Default)
Mark Atwood

October 2017

1 234567
1516 1718192021

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Oct. 21st, 2017 08:43 am
Powered by Dreamwidth Studios