When trying out non ASCII utf-8 sequence in println!(), the console outputs scrambled characters.
Code:
fn main() {
println!("你好,世界!");
}
Output;
浣犲ソ锛屼笘鐣岋紒
When executed after chcp 65001, this gives the correct result. I understand that stdout is also used with redirection and the implementation interprets the console behavior from getting is window and such, as a result this is also not a problem when running directly.
But will happen so when executed in debugging consoles like the one in vscode. Is there any easy solution to the encoding problem?
It sounds like your console is interpreting the strings in a different encoding than utf-8. The easiest would be to configure the terminal to read it with the appropriate encoding, although you could also try to insert a layer in your code that converts the text to some other encoding before writing it to stdout.