Questions tagged [unpack]

A function in several scripting languages for unpacking binary data into native types for the language in question. The opposite of the 'pack' function. For the Python concept, use 'iterable-unpacking'. This tag should be used with a programming language tag as well. While also used as directive or pragma in some compilers to ignore standard variable alignment for data aggregates (i.e. struct), do not use this tag for posts on that subject.

The unpack function parses a binary string into several variables with types that are native to the language in question. The binary string usually matches the machine-level representation that you would see in a C . The inverse operation is .

For Python use .

Most versions of unpack and pack functions use a format or template that specifies the byte by byte layout of the data being copied out of or put into the memory area containing the binary representation.

Both functions allow the use of C or C++ routines with complex data structures to be used with the scripting language in order to improve application performance or to perform operations and actions not available in the scripting language.

Documentation:

529 questions
-3
votes
3 answers

How to print a string before using "*" to unpack list

Is it possible to print a string before using the * operator when unpacking a tuple: m = ['b', 'a', 'e'] print(*m, sep = ',') b, a, e I tried to print something before it: print("String: " + *m, sep = ",") My desired output would be: String: b,…
ter123
  • 13
  • 4
-4
votes
2 answers

ValueError: too many values to unpack (Python 2.7)

values = data.split("\x00") username, passwordHash, startRoom, originUrl, bs64encode = values if len(passwordHash)!= 0 and len(passwordHash)!= 64: passwordHash = "" if passwordHash != "": passwordHash =…
Ionuț
  • 57
  • 1
  • 1
  • 9
-4
votes
2 answers

Pack and unpack in Perl

I confused with pack and unpack while writing a Perl script. What is the difference between between pack and unpack in Perl (explain with a simple example)?
-5
votes
2 answers

How do I use Perl's unpack?

I have an JSON Body of an http post that has to be split into 80 character double quoted strings - but - whenever I use unpack to read the first 80 characters, the string pointer in the source string (which is not CR/LF delimited at the end of each…
1 2 3
35
36