1
0
Fork 0
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:
Henrik Hautakoski 2026-06-26 09:46:08 +02:00
parent 08c67dfa19
commit 0fa93d691c
2 changed files with 47 additions and 0 deletions

View file

@ -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);
}
}