Reputation: 3790
Im reading a CSV file that was created from MS Excel. When I open it up in notepad it looks ok, but in Notepad++ I change the Encoding from ANSI
to UTF8
and a few non printed characters turn up.
Specifically xFF. -(HEX Value)
In my C# app this character is causing an issue when reading the file so is there a way I can do a String.replace('xFF', ' ');
on this?
I found this link on SO, as it turns out it is the answer to my question but not my problem. Link
Upvotes: 1
Views: 230
Reputation: 3686
Guess your unicode representation is wrong. Try this
string foo = "foo\xff";
foo.Replace('\xff',' ');
Upvotes: 1
Reputation: 30688
Instead of String.Replace, Specify encoding while reading the file.
Example
File.ReadAllText("test.csv",System.Text.UTF8Encoding)
Upvotes: 2