Hello,
i have a strange string escaping problem. With the crate rust-ini i read some keys with values and i have say rust-ini please deliver the quotes as is.
[test]
path="%Userprofile/followingpathwithnowhitespace".
So an now i want to give an command this path and i have thinked that the quotes will be delivered, but at my tests i think rust do it own logic.
A string with whitespaces became quotes and a string without become no quotes.
So Problem %Userprofile" inlcude whitespace .
Tja the i have thinked, cool the make i and condition:
if (opt_ytdl["save_location"].contains ("%UserProfile%") && !(opt_ytdl["save_location"].contains (" ")))
and then i format the string without quotes with quotes
let test: String = format!("{}",&opt_ytdl["save_location"]);
println!("{:?}", &test); // "\"%UserProfile%\\pfadwithnows\""
println!("{}", &test); // "%UserProfile%\pfadwithnows"
Okay so when i push this &test to an command.arg(&test), then he put the debuggend escpade string with " in that argument.
Seems like that i overwrite an rust internal thing. Can it be that rust take the choice what variable became quotes and what variable not?
When the condition is not met and i overgive the string as is to command.arg then all functioned one string with quotes and the cmd /k echo %1 gives the correct path:
"c:\user\user with ws\pfadwithnows"
I think rust-ini make it right an give an string with quotes to rust and rust say "oooh string without space needs no double quotes" and patch the double quotes away, right?
Edit, when i put an whitespace in rust-ini
path="asdsa asdl sadsa dsa d"
the raw string {}-> "asdsa asdl sadsa dsa d"
path="asdsaasdlsadsadsad"
the raw string {}-> asdsa asdl sadsa dsa d