1
0
Fork 0
mirror of https://codeberg.org/icewind/bitbuffer.git synced 2026-06-03 16:44:06 +02:00

no need to trim dynamic length strings

This commit is contained in:
Robin Appelman 2019-03-08 22:03:41 +01:00
commit 1c82edd402

View file

@ -383,7 +383,11 @@ where
pub fn read_string(&self, position: usize, byte_len: Option<usize>) -> Result<String> {
let bytes = self.read_string_bytes(position, byte_len)?;
let raw_string = String::from_utf8(bytes)?;
Ok(raw_string.trim_end_matches(char::from(0)).to_owned())
if byte_len.is_some() {
Ok(raw_string.trim_end_matches(char::from(0)).to_owned())
} else {
Ok(raw_string)
}
}
fn read_string_bytes(&self, position: usize, byte_len: Option<usize>) -> Result<Vec<u8>> {