If we want to create a complex string (that is, we need to use the original string, and cannot use the escape character \r\n) and need "CRLF" as the newline character, it does not work to save the source code file as "CRLF". The string always uses "LF" as the newline character
The code is as follows:
fn main() {
let json_str = r#"{
"name":"zhang_san",
"age":"13"
}"#;
//Expected output:
//"{\r\n \"name\":\"zhang_san\",\r\n \"age\":\"13\"\r\n}"
//Actual output:
//"{\n \"name\":\"zhang_san\",\n \"age\":\"13\"\n}"
println!("{:?}",json_str);
}
Does the compiler need to make changes, such as: let the string follow the newline character of the source code, or add an error prompt“ error:couldn't read src\ main.rs : stream did not contain valid LF ", just like" error: couldn't read src\ main.rs : stream did not contain valid UTF-8".
The above is machine translation, my English is not good