mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-20 16:00:20 +00:00
Added methods for endian-flipping
This commit is contained in:
parent
10ff2948ac
commit
23eb8600ab
@ -55,6 +55,20 @@ class Binary{
|
||||
return $value & 0xffffffff;
|
||||
}
|
||||
|
||||
|
||||
public static function flipShortEndianness(int $value) : int{
|
||||
return self::readLShort(self::writeShort($value));
|
||||
}
|
||||
|
||||
public static function flipIntEndianness(int $value) : int{
|
||||
return self::readLInt(self::writeInt($value));
|
||||
}
|
||||
|
||||
public static function flipLongEndianness(int $value) : int{
|
||||
return self::readLLong(self::writeLong($value));
|
||||
}
|
||||
|
||||
|
||||
private static function checkLength($str, $expect){
|
||||
assert(($len = strlen($str)) === $expect, "Expected $expect bytes, got $len");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user