c# encoding problems (question marks) while reading file from StreamReader
c#, encoding
Solution
You need to use Encoding.Default. Change:
using (var reader = new StreamReader(resourceStream.Stream, System.Text.Encoding.UTF8))
to
using (var reader = new StreamReader(resourceStream.Stream, System.Text.Encoding.Default))
Problem
I've a problem while reading a .txt file from my Windows Phone app. I've made a simple app, that reads a stream from a .txt file and prints it. Unfortunately I'm from Italy and we've many letters with accents. And here's the problem, in fact all accented letters are printed as a question mark. Here's the sample code: ``` var resourceStream = Application.GetResourceStream(new Uri("frasi.txt",UriKind.RelativeOrAbsolute)); if (resourceStream != null) { { //System.Text.Encoding.Default, true using (var reader = new StreamReader(resourceStream.Stream, System.Text.Encoding.UTF8)) { string line; line = reader.ReadLine(); while (line != null) { frasi.Add(line); line = reader.ReadLine(); } } } ``` So, I'm asking you how to avoid this matter. All the best. [EDIT:] Solution: I didn't make sure the file was encoded in UTF-8- I saved it with the correct encoding and it worked like a charm. thank you Oscar