Have some text files that display many characters as � in TextBox and TextBlock.
How can I properly read and display these files in .NET WPF?
File read where fi is a FileInfo.
fileText = fi.OpenText().ReadToEnd();
In WPF I get the � character for ü ò ° and other special characters.
Have tried multiple fonts.
Culture is en-EN.
If I read the file as a Stream I get the special characters
System.IO.Stream fsIn = fi.OpenRead();
if (fsIn.Length == 0) return;
int curInt = -1;
StringBuilder sb = new StringBuilder();
while ((curInt = fsIn.ReadByte()) >= 0)
{
sb.Append((char)curInt);
}
OpenText() appears to be reading all the special characters as byte 253
What I think I have learned is the text is not UTF8 encoded. UTF8 uses 128-255 for control. OpenText() is used for UTF8 encoding. WikiUFT8