mirror of
https://github.com/shufflingpixels/php-io.git
synced 2026-10-19 06:26:46 +02:00
Add BinaryReader::readPaddedString
This commit is contained in:
parent
08c67dfa19
commit
0fa93d691c
2 changed files with 47 additions and 0 deletions
|
|
@ -129,4 +129,13 @@ class BinaryReader
|
|||
|
||||
return $value >= 0x8000_0000 ? $value - 0x1_0000_0000 : $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a string of fixed length, trimming any padding characters from the end.
|
||||
*/
|
||||
public function readPaddedString(int $length, string $pad_chars = "\x00") : string
|
||||
{
|
||||
$data = $this->read($length);
|
||||
return rtrim($data, $pad_chars);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue