Skip to content

Commit

Permalink
Patch fixing redux: Trim trailing null characters
Browse files Browse the repository at this point in the history
This fixes broken file operations
  • Loading branch information
redstrate committed Jul 18, 2024
1 parent 4d23bf9 commit 66034b6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/common_file_operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ pub(crate) fn write_bool_as<T: std::convert::From<u8>>(x: &bool) -> T {
}

pub(crate) fn read_string(byte_stream: Vec<u8>) -> String {
String::from_utf8(byte_stream).unwrap()
let str = String::from_utf8(byte_stream).unwrap();
str.trim_matches(char::from(0)).to_string() // trim \0 from the end of strings
}

pub(crate) fn write_string(str: &String) -> Vec<u8> {
Expand Down

0 comments on commit 66034b6

Please sign in to comment.