Extract an unsigned byte from a string of bytes.
static
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.
static
void
bytesToDump
(string $bytes, [int $max = 0])
-
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.
static
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.
static
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.
static
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.
static
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.
static
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.
static
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.
static
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 an unsigned long into four bytes.
Because PHP limits the size of integers to 32 bit signed, one cannot really have an unsigned integer in PHP. But integers larger than 2^31-1 will be promoted to 64 bit signed floating point numbers, and so such large numbers can be handled too.
static
string
longToBytes
(int $value, PelByteOrder $endian)
-
int
$value: the unsigned long that will be converted. The argument will be treated as an unsigned 32 bit integer and the lower four bytes will be extracted. Treating the argument as an unsigned integer means that the absolute value will be used. Use sLongToBytes to convert signed integers.
-
PelByteOrder
$endian: one of LITTLE_ENDIAN and BIG_ENDIAN.
Convert an unsigned short into two bytes.
static
string
shortToBytes
(int $value, PelByteOrder $endian)
-
int
$value: the unsigned 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.
Convert a signed long into four bytes.
static
string
sLongToBytes
(int $value, PelByteOrder $endian)
-
int
$value: the signed long that will be converted. The argument will be treated as a signed 32 bit integer, from which the lower four bytes will be extracted.
-
PelByteOrder
$endian: one of LITTLE_ENDIAN and BIG_ENDIAN.
Convert a signed short into two bytes.
static
string
sShortToBytes
(int $value, PelByteOrder $endian)
-
int
$value: the signed 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.