When I run the program in Rust Playground, I get the following output:
<--- ååå
ööö
äää--->
When the program is run from the command line using "cargo run", the output is as follows:
<--- ååå
ööö
äää--->
Strangely, spaces are added at the beginning of lines 2 and 3. However, when the program is run in Visual Studio Code, the Swedish characters get distorted.
<--- ååå
├╢├╢├╢
äää--->
Does anybody understand this behavior?
Actually, I work with Regex, and the patterns I'm using don't do what they are supposed to do, and I suspect it to be caused by the character set used in the VSC.
Probably it's the Microsoft ecosystem still trying to force Latin-1 (ISO-8859-1) down your throat? I wouldn't be surprised if, instead of today's sensible default of UTF-8, VS was trying to save your programs in this other encoding.
Yeah, the file encoding seems to be UTF-8 as expected, but the VSC terminal interprets it as – not even Latin-1 (which doesn’t have those line drawing characters) – but the venerable and nonstandard MS/IBM code page 437 from the early 80s! No doubt due to some particularly misguided backwards compatibility concern.
Any ideas on how to solve it? martys71 seems to suggest setting the terminal font to something strange for me: MesloLGS NF. I'm not sure I want to experiment; I don't know how to restore things.
Perhaps you just indented the code by 4 spaces, including inside the string literal?
BTW: These are not "ANSI" characters, they are Unicode characters encoded in UTF-8 (so each Swedish character is two bytes). "ANSI" is an ambiguous term but it typically refers to some single-byte encoding.
I've posted an equivalent question on Stack Overflow and it is already solved by editing the VSC settings; see Visual Studio Code distorts ANSI characters for more details.