lossy utf8

This commit is contained in:
Robin Appelman 2023-03-27 19:21:20 +02:00
commit b95c58a257
2 changed files with 4 additions and 2 deletions

View file

@ -57,13 +57,14 @@ fn main() -> Result<(), MainError> {
if path.extension() == Some(OsStr::new("log")) { if path.extension() == Some(OsStr::new("log")) {
// let _ = print!("{} - ", path.display()); // let _ = print!("{} - ", path.display());
let read_start = Instant::now(); let read_start = Instant::now();
let input = match fs::read_to_string(path) { let input = match fs::read(path) {
Ok(input) => input, Ok(input) => input,
Err(_e) => { Err(_e) => {
// println!("failed to read file: {}", e); // println!("failed to read file: {}", e);
return; return;
} }
}; };
let input = String::from_utf8_lossy(&input);
read_time.fetch_add(read_start.elapsed().as_micros() as usize, Ordering::Relaxed); read_time.fetch_add(read_start.elapsed().as_micros() as usize, Ordering::Relaxed);
let parse_start = Instant::now(); let parse_start = Instant::now();

View file

@ -6,7 +6,8 @@ use tf_log_parser::parse;
fn main() -> Result<(), MainError> { fn main() -> Result<(), MainError> {
let path = args().nth(1).expect("No path provided"); let path = args().nth(1).expect("No path provided");
let content = fs::read_to_string(path)?; let content = fs::read(path)?;
let content = String::from_utf8_lossy(&content);
let log = parse(&content)?; let log = parse(&content)?;