[Mono-list] System.Text.Encoding and StreamReader

Andy Hume andyhume32 at yahoo.co.uk
Sat Sep 13 08:16:34 EDT 2008

StreamReader wants an Encoding, so create a suitable one and pass it in! :-) 
To create an Encoding see its GetEncoding method.  You want to pass in
"iso-8859-15" or 28605.  For example:

StreamReader srAsciiFromFile = new StreamReader(@"testfile.csv",


Paul F. Johnson wrote:
> I've been looking at how to read in a CSV file which is in ISO-8559-15
> form (that is to say, saved out as ISO-8859-15).
> I'm now looking at a way of bringing the CSV file back in to a little
> program of mine, but I'm unsure of what I need to do so that it's read
> as ISO-8859-15.
> Looking at MSDN, System.Text.Encoding looks to be what I need with a
> line akin to 
> StreamReader srAsciiFromFile = new StreamReader(@"testfile.csv",
> System.Text.Encoding.ASCII);
> Obviously Encoding.ASCII would not be right for 8859-15, but looking at
> MSDN for System.Text.Encoding, it looks like I need to set the codepage
> as 28605
> (http://msdn.microsoft.com/en-us/library/system.text.encoding(VS.80).aspx)
> but there isn't really a SetEncoding method for reading and
> Encoding.Unicode looks to be right, but I'm not sure if it will support
> 8859-15
> Any help on this would be appreciated.
> Paul
> -- 
> Sie können mich aufreizen und wirklich heiß machen!
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list

View this message in context: http://www.nabble.com/System.Text.Encoding-and-StreamReader-tp19469538p19469996.html
Sent from the Mono - General mailing list archive at Nabble.com.

More information about the Mono-list mailing list