Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FileHelpers - How to read in ® character?

Tags:

c#

filehelpers

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.

like image 421
Ryan Drost Avatar asked Sep 05 '13 14:09

Ryan Drost


1 Answers

Set the proper encoding on your StreamReader.

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

like image 173
spender Avatar answered Sep 24 '22 17:09

spender