Search code examples
c#filehelpers

FileHelpers - How to read in ® character?


I am reading in a CSV file and everything is working correctly. All fields are going to the correct places but it is converting ® to �.

var engine = new FileHelperEngine(typeof(T));
return engine.ReadStream(new StreamReader(stream)) as T[];

Any ideas on how to prevent this from happening?

EDIT:

With the help of spender I got this to work:

var engine = new FileHelperEngine(typeof(T), Encoding.UTF8);
return engine.ReadStream(new StreamReader(stream, Encoding.UTF8)) as T[];

I had to set the encoding in BOTH places for this to work. Otherwise I saw weird results.


Solution

  • Set the proper encoding on your StreamReader.

    http://msdn.microsoft.com/en-us/library/ms143456.aspx