rust-shell-script / rust_cmd_lib

Common rust command-line macros and utilities, to write shell-script like tasks in a clean, natural and rusty way
https://docs.rs/cmd_lib/
Apache License 2.0
1.05k stars 37 forks source link

How to output Chinese and correct code #26

Closed shijunti19 closed 3 years ago

shijunti19 commented 3 years ago

image

run_fun Chinese is not displayed

image

The correct output should be:f:\web\xiaolu\rust\监听命令\a031

I can't transcode with encoding

rust-shell-script commented 3 years ago

The Chinese output would be just fine for valid strings, see https://github.com/rust-shell-script/rust_cmd_lib/blob/0b6e05b9fefe818137fe5044c55e854c7abddadd/tests/test_macros.rs#L94 and https://github.com/rust-shell-script/rust_cmd_lib/blob/0b6e05b9fefe818137fe5044c55e854c7abddadd/tests/test_macros.rs#L227

The problem is that the output from your script is not valid utf8 strings, however you can spawn!(1.bat)?.wait_with_pipe(...) to decode the the raw output for this case. Since I don't have a working windows environment, sorry I can not provide further suggestions.