I’m loading a file with a filepicker and something goes wrong with the encoding. I don’t get the right special chars. Here is the code:
StorageFile file = await openPicker.PickSingleFileAsync();
if (file != null)
{
var stream = await file.OpenReadAsync();
var rdr = new StreamReader(stream.AsStream());
}
The reading works perfect, but the encoding not. The file comes in as an ansi-csv file. I can give the StreamReader a encoding like this:
var rdr = new StreamReader(stream.AsStream(),System.Text.Encoding.UTF8);
But this also dosn’t work and an System.Text.Encoding.ANSI encoding dosn’t exist. How can I read the file with the correct Encoding and display my special chars?
You can specify the current ANSI encoding for the system:
If that is not the correct encoding for the file, then you need to know which encoding was used on the computer where the file was created, and get that encoding to decode it. For example: