Differences between PHP and Python pack/unpack format characters
php | python | ||
NUL-padded string | a | ||
SPACE-padded string | A | ||
Hex string, low nibble first | h | ||
Hex string, high nibble first | H | ||
signed char | c | b | signed char |
unsigned char | C | B | unsigned char |
signed short (always 16 bit, machine byte order) | s | h | short |
unsigned short (always 16 bit, machine byte order) | S | H | unsigned short |
unsigned short (always 16 bit, big endian byte order) | n | i | int |
unsigned short (always 16 bit, little endian byte order) | v | I | unsigned int |
signed integer (machine dependent size and byte order) | i | i | int |
unsigned integer (machine dependent size and byte order) | I | I | unsigned int |
signed long (always 32 bit, machine byte order) | l | l | long |
unsigned long (always 32 bit, machine byte order) | L | L | unsigned long |
unsigned long (always 32 bit, big endian byte order) | N | ||
unsigned long (always 32 bit, little endian byte order) | V | ||
signed long long (always 64 bit, machine byte order) | q | q | long long |
unsigned long long (always 64 bit, machine byte order) | Q | Q | unsigned long long |
unsigned long long (always 64 bit, big endian byte order) | J | ||
unsigned long long (always 64 bit, little endian byte order) | P | ||
float (machine dependent size and representation) | f | f | float |
float (machine dependent size, little endian byte order) | g | ||
float (machine dependent size, big endian byte order) | G | ||
double (machine dependent size and representation) | d | d | double |
double (machine dependent size, little endian byte order) | e | ||
double (machine dependent size, big endian byte order) | E | ||
NUL byte | x | ||
Back up one byte | X | ||
NUL-padded string (new in PHP 5.5) | Z | ||
NUL-fill to absolute position | @ | ||
x | pad byte | ||
c | char | ||
? | _Bool | ||
s | char[] | ||
p | char[] | ||
P | void * |