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:
parent
0a5daeb62d
commit
1c82edd402
1 changed files with 5 additions and 1 deletions
|
|
@ -383,7 +383,11 @@ where
|
||||||
pub fn read_string(&self, position: usize, byte_len: Option<usize>) -> Result<String> {
|
pub fn read_string(&self, position: usize, byte_len: Option<usize>) -> Result<String> {
|
||||||
let bytes = self.read_string_bytes(position, byte_len)?;
|
let bytes = self.read_string_bytes(position, byte_len)?;
|
||||||
let raw_string = String::from_utf8(bytes)?;
|
let raw_string = String::from_utf8(bytes)?;
|
||||||
|
if byte_len.is_some() {
|
||||||
Ok(raw_string.trim_end_matches(char::from(0)).to_owned())
|
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>> {
|
fn read_string_bytes(&self, position: usize, byte_len: Option<usize>) -> Result<Vec<u8>> {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue