Extract an unsigned byte from a string of bytes.
int
bytesToByte
(string &$bytes, int $offset)
-
string
&$bytes: the bytes.
-
int
$offset: the offset. The byte found at the offset will be returned as an integer. The must be at least one byte available at offset.
Format bytes for dumping.
This method is for debug output, it will format a string as a hexadecimal dump suitable for display on a terminal. The output is printed directly to standard out.
void
bytesToDump
(string $bytes, int $max)
-
string
$bytes: the bytes that will be dumped.
-
int
$max: the maximum number of bytes to dump. If this is left out (or left to the default of 0), then the entire string will be dumped.
Extract an unsigned long from bytes.
int
bytesToLong
(string &$bytes, int $offset, PelByteOrder $endian)
-
string
&$bytes: the bytes.
-
int
$offset: the offset. The long found at offset will be returned as an integer. There must be at least four bytes available beginning at the offset given.
-
PelByteOrder
$endian: one of LITTLE_ENDIAN and BIG_ENDIAN.
Extract an unsigned rational from bytes.
array
bytesToRational
(string &$bytes, int $offset, PelByteOrder $endian)
-
string
&$bytes: the bytes.
-
int
$offset: the offset. The rational found at offset will be returned as an array. There must be at least eight bytes available beginning at the offset given.
-
PelByteOrder
$endian: one of LITTLE_ENDIAN and BIG_ENDIAN.
Extract a signed byte from bytes.
int
bytesToSByte
(string &$bytes, int $offset)
-
string
&$bytes: the bytes.
-
int
$offset: the offset. The byte found at the offset will be returned as an integer. The must be at least one byte available at offset.
Extract an unsigned short from bytes.
int
bytesToShort
(string &$bytes, int $offset, PelByteOrder $endian)
-
string
&$bytes: the bytes.
-
int
$offset: the offset. The short found at the offset will be returned as an integer. There must be at least two bytes available beginning at the offset given.
-
PelByteOrder
$endian: one of LITTLE_ENDIAN and BIG_ENDIAN.
Extract a signed long from bytes.
int
bytesToSLong
(string &$bytes, int $offset, PelByteOrder $endian)
-
string
&$bytes: the bytes.
-
int
$offset: the offset. The long found at offset will be returned as an integer. There must be at least four bytes available beginning at the offset given.
-
PelByteOrder
$endian: one of LITTLE_ENDIAN and BIG_ENDIAN.
Extract a signed rational from bytes.
array
bytesToSRational
(string &$bytes, int $offset, PelByteOrder $endian)
-
string
&$bytes: the bytes.
-
int
$offset: the offset. The rational found at offset will be returned as an array. There must be at least eight bytes available beginning at the offset given.
-
PelByteOrder
$endian: one of LITTLE_ENDIAN and BIG_ENDIAN.
Extract a signed short from bytes.
int
bytesToSShort
(string &$bytes, int $offset, PelByteOrder $endian)
-
string
&$bytes: the bytes.
-
int
$offset: the offset. The short found at offset will be returned as an integer. There must be at least two bytes available beginning at the offset given.
-
PelByteOrder
$endian: one of LITTLE_ENDIAN and BIG_ENDIAN.
Convert a long into two bytes.
string
longToBytes
(int $value, PelByteOrder $endian)
-
int
$value: the long that will be converted. The lower four bytes will be extracted regardless of the actual size passed.
-
PelByteOrder
$endian: one of LITTLE_ENDIAN and BIG_ENDIAN.
Convert a short into two bytes.
string
shortToBytes
(int $value, PelByteOrder $endian)
-
int
$value: the short that will be converted. The lower two bytes will be extracted regardless of the actual size passed.
-
PelByteOrder
$endian: one of LITTLE_ENDIAN and BIG_ENDIAN.