I have read a certain plain text file (csv) and I have a problem with xA0
Visual Studio 2015:
Notepad++: (when setting char encoding to utf-8)
so it seems to be this non-breaking space so I tried this:
temp = temp.Replace("\xA0", string.Empty);
But it did not work and gave me the black squares similar to the first screenshot. I also changed
System.IO.StreamReader sr = new System.IO.StreamReader(csvFile.FileContent);
to use specific utf-8 encoding:
System.IO.StreamReader sr = new System.IO.StreamReader(csvFile.FileContent, System.Text.Encoding.UTF8);
both gave the same result. I really dislike char encoding and could use some help and explanation about my mistake.
edit added the notepad++ hex view: (to confirm it is the non-breaking char)
edit2 changing the streamreader constructor values to this:
System.IO.StreamReader sr = new System.IO.StreamReader(csvFile.FileContent, true);
results in an utf-8 encoding for reading the file. I tried to convert the latin1 to utf-8 but that gave me ???
https://stackoverflow.com/a/13999801/169714
Encoding.UTF8.GetString(Encoding.GetEncoding("iso-8859-1").GetBytes(temp))