I use the code below to read a text file containing foreign characters, the file is ANSI encoded and looks great in notepad. The code below does not work when the file values ββare read and displayed in the datagrid, the characters are displayed as squares, maybe there is another problem elsewhere?
StreamReader reader = new StreamReader(inputFilePath, System.Text.Encoding.ANSI); using (reader = File.OpenText(inputFilePath))
thank
Update 1 . I tried all the encodings found in System.Text.Encoding . and all do not display the file correctly.
Update 2 . I changed the encoding of the file (saved the file) to unicode and used System.Text.Encoding.Unicode , and it worked fine. So why did the notebook read it correctly? And why didn't System.Text.Encoding.Unicode read the ANSI file?
c # encoding
Scott Feb 26 '09 at 22:55 2009-02-26 22:55
source share