Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
112 lines (111 sloc) 6.69 KB
---
unpack: |-
================================================================================
String#unpack
================================================================================
Format | Returns | Function
-------+---------+-----------------------------------------
A | String | with trailing nulls and spaces removed
-------+---------+-----------------------------------------
a | String | string
-------+---------+-----------------------------------------
B | String | extract bits from each character (msb first)
-------+---------+-----------------------------------------
b | String | extract bits from each character (lsb first)
-------+---------+-----------------------------------------
C | Fixnum | extract a character as an unsigned integer
-------+---------+-----------------------------------------
c | Fixnum | extract a character as an integer
-------+---------+-----------------------------------------
d,D | Float | treat sizeof(double) characters as
| | a native double
-------+---------+-----------------------------------------
E | Float | treat sizeof(double) characters as
| | a double in little-endian byte order
-------+---------+-----------------------------------------
e | Float | treat sizeof(float) characters as
| | a float in little-endian byte order
-------+---------+-----------------------------------------
f,F | Float | treat sizeof(float) characters as
| | a native float
-------+---------+-----------------------------------------
G | Float | treat sizeof(double) characters as
| | a double in network byte order
-------+---------+-----------------------------------------
g | Float | treat sizeof(float) characters as a
| | float in network byte order
-------+---------+-----------------------------------------
H | String | extract hex nibbles from each character
| | (most significant first)
-------+---------+-----------------------------------------
h | String | extract hex nibbles from each character
| | (least significant first)
-------+---------+-----------------------------------------
I | Integer | treat sizeof(int) (modified by _)
| | successive characters as an unsigned
| | native integer
-------+---------+-----------------------------------------
i | Integer | treat sizeof(int) (modified by _)
| | successive characters as a signed
| | native integer
-------+---------+-----------------------------------------
L | Integer | treat four (modified by _) successive
| | characters as an unsigned native
| | long integer
-------+---------+-----------------------------------------
l | Integer | treat four (modified by _) successive
| | characters as a signed native
| | long integer
-------+---------+-----------------------------------------
M | String | quoted-printable
-------+---------+-----------------------------------------
m | String | base64-encoded
-------+---------+-----------------------------------------
N | Integer | treat four characters as an unsigned
| | long in network byte order
-------+---------+-----------------------------------------
n | Fixnum | treat two characters as an unsigned
| | short in network byte order
-------+---------+-----------------------------------------
P | String | treat sizeof(char *) characters as a
| | pointer, and return \emph{len} characters
| | from the referenced location
-------+---------+-----------------------------------------
p | String | treat sizeof(char *) characters as a
| | pointer to a null-terminated string
-------+---------+-----------------------------------------
Q | Integer | treat 8 characters as an unsigned
| | quad word (64 bits)
-------+---------+-----------------------------------------
q | Integer | treat 8 characters as a signed
| | quad word (64 bits)
-------+---------+-----------------------------------------
S | Fixnum | treat two (different if _ used)
| | successive characters as an unsigned
| | short in native byte order
-------+---------+-----------------------------------------
s | Fixnum | Treat two (different if _ used)
| | successive characters as a signed short
| | in native byte order
-------+---------+-----------------------------------------
U | Integer | UTF-8 characters as unsigned integers
-------+---------+-----------------------------------------
u | String | UU-encoded
-------+---------+-----------------------------------------
V | Fixnum | treat four characters as an unsigned
| | long in little-endian byte order
-------+---------+-----------------------------------------
v | Fixnum | treat two characters as an unsigned
| | short in little-endian byte order
-------+---------+-----------------------------------------
w | Integer | BER-compressed integer (see Array.pack)
-------+---------+-----------------------------------------
X | --- | skip backward one character
-------+---------+-----------------------------------------
x | --- | skip forward one character
-------+---------+-----------------------------------------
Z | String | with trailing nulls removed
| | upto first null with *
-------+---------+-----------------------------------------
@ | --- | skip to the offset given by the
| | length argument