Skip to content

Commit

Permalink
use utf8 lossy
Browse files Browse the repository at this point in the history
  • Loading branch information
thecodingwizard committed Jul 31, 2024
1 parent b079d9a commit 4a82199
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,19 @@ SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior solution.cpp:15:8
*/
// which is what leetcode gives you
```

Better logging: https://docs.aws.amazon.com/lambda/latest/dg/rust-logging.html

utf8 encoding regression test:

```
// Source: https://usaco.guide/general/io
#include <bits/stdc++.h>
using namespace std;
int main() {
char c = 128;
cout << c << endl;
}
```
4 changes: 2 additions & 2 deletions src/run_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ pub fn run_command(

let process = process.wait_with_output()?;

let timing_output = parse_timing_stderr(str::from_utf8(&process.stderr)?)?;
let timing_output = parse_timing_stderr(String::from_utf8_lossy(&process.stderr).as_ref())?;

Ok(CommandOutput {
exit_code: process.status.into_raw(),
Expand All @@ -125,7 +125,7 @@ pub fn run_command(
signal.to_string()
})
}),
stdout: str::from_utf8(&process.stdout)?.to_string(),
stdout: String::from_utf8_lossy(&process.stdout).into_owned(),
stderr: timing_output.stderr,
wall_time: timing_output.wall_time,
memory_usage: timing_output.memory_usage,
Expand Down

0 comments on commit 4a82199

Please sign in to comment.