I have a dbf file which has MONTRÉAL
as one of the entires. I have to convert this dbf file into a csv file.
For this I am reading this dbf file using Microsoft Visual FoxPro Driver driver, then converting converting each rows to comma separated, and then writing all lines into a file named "ASD.csv".
But in CSV file MONTRÉAL
is displayed as MONTR?AL
i.e in place of É
a ?
character appears. I tried using UTF8 encoding while writing the rows to csv file but even this did not work.
Please help.
French Characters in HTML Documents - UTF-8 Encoding. This section provides a tutorial example on how enter and use French characters in HTML documents using Unicode UTF-8 encoding. The HTML document should include a meta tag with charset=utf-8 and be stored in UTF-8 format.
Chances are, you will run into special characters within your data. So if you're working with CSV, what special characters are actually supported? Technically, all of them! There are no specified limits of what characters can be used in a CSV file.
Simple CSV files do not support Unicode/UTF-8 characters. This is a limitation of the CSV format and not something that can be changed in DEAR. However, it is possible to import/export Unicode characters following these steps. This article shows the process for Windows machines.
It is recommended to always use UTF-8 encoding in your CSV files. Why? UTF-8 encoding contains 1,112,064 characters, which encompasses just about any character you would type, in any language.
you have to use a specific encoding. for french it is "iso-8859-1" or "windows-1252".
Encoding.GetEncoding("iso-8859-1")
I suggest you use UTF8 encoding like this:
using (StreamWriter writer = new StreamWriter("asd.csv", false, Encoding.UTF8))
{
writer.WriteLine("Id;City");
writer.WriteLine("1;Montréal");
writer.WriteLine("2;Québec");
}
This will add a BOM (Byte Order Mark) to the beginning of the CSV and you can then open the file with Excel directly, or even with the standard Windows Notepad successfully.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With