Function e_utils::system::encode::auto_decode
source · pub fn auto_decode(content: &[u8]) -> Option<String>Expand description
自动检测编码并解码
use e_utils::system::encode::auto_decode;
fn main() {
let stdout = b"out -> \xe4\xbd\xa0\xe5\xa5\xbd: \xe6\x88\x91\xe4\xb8\x8d\xe8\x83\xbd\xe8\xae\xa4\xe8\xaf\x86\xe8\xaf\xad\xe8\xa8\x80\r\n\r\n Windows \xe6\x9c\xaa\xe6\xbf\x80\xe6\xb4\xbb";
if let Some(txt) = auto_decode(stdout) {
println!("{:?}", txt);
} else {
println!("Failed to decode the content");
}
}