I want to execute a shell command using Rust. My code is equivalent to the following:
let mut command = std::process::Command::new("cmd").args(&["/c", "my-command"]);
let output = process.output()?;
The problem I’m facing is that the output of my-command
contains characters like テスト
, and those characters are converted to ???
when reading the output (stdout
). I believe my problem can be solved by using the method fmt since, as the documentation says, the default formatter works as follows (which I believe is my problem):
Any non-utf8 data is lossily converted using the utf8 replacement
character.
However, I am struggling to provide my own formatter for my command
.
How can this be solved? Thanks.
0