How to read Swedish characters properly from a txt file
c#, character-encoding, encoding, file, stream
Solution
You need to change the System.Text.Encoding.UTF8 to System.Text.Encoding.GetEncoding(1252). See below
System.IO.TextReader tr = new System.IO.StreamReader(@"c:\testfile.txt", System.Text.Encoding.GetEncoding(1252), true);
tr.ReadLine(); //returns a string but Swedish characters are not appearing correctly
Problem
I am reading a file (line by line) full of Swedish characters like äåö but how can I read and save the strings with Swedish characters. Here is my code and I am using UTF8 encoding: ``` TextReader tr = new StreamReader(@"c:\testfile.txt", System.Text.Encoding.UTF8, true); tr.ReadLine() //returns a string but Swedish characters are not appearing correctly... ```