File.WriteAllLines do not write the letters æ, ø

I have a string array "s" and then File.WriteAllLines(path, s); , and when I open the file, æ and ø are replaced by. How can i fix this?

+6
source share
2 answers

Both File.WriteAllLines and File.WriteAllText use UTF-8 unless Encoding specified. In particular, this is UTF-8 without a specification (which is pretty normal).

So: either read the file with an editor that understands UTF-8, or explicitly specify the alternative Encoding that you want to use.

+8
source

I solved the problem: File.WriteAllLines(path, s, Encoding.UTF8);

+1
source

Source: https://habr.com/ru/post/952449/


All Articles