Encoding in CSV file not able to handle special character

65 views Asked by At

I have a CSV with the below content.

1001,01 ░ - 02 Room,India,0

And below is my code:

string row = "1001,01 ░ - 02 Room,India,0"
File.WriteAllText("MyCsv.csv", row);

It successfully creates MyCsv.csv, When I open this file with notepad this is what is see:

enter image description here

But when i open it with excel, this is what i see:

enter image description here

So basically "01 ░ - 02 Room" gets converted to "01 â–‘ - 02 Room" on opening with excel.

How to avoid this conversion? I want to see "01 ░ - 02 Room" on excel also.

1

There are 1 answers

0
Anushree Sengupta On

File.WriteAllText("MyCsv.csv", row,Encoding.UTF8); resolved the issue