I have a problem reading a .txt file from my Windows Phone application.
I made a simple application that reads a stream from a TXT file and prints it.
Unfortunately, I am from Italy and we have many letters with accents. And here is the problem, because all letters with an accent are printed as a question mark.
Here is a sample code:
var resourceStream = Application.GetResourceStream(new Uri("frasi.txt",UriKind.RelativeOrAbsolute));
if (resourceStream != null)
{
{
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 ask you how to avoid this.
All the best.
[EDIT:] Solution: I did not make sure that the file was encoded in UTF-8. I saved it with the correct encoding, and it worked like a charm. thank you oscar
ubi_v source
share