My issue is displaying european characters like 'ä' and 'ö' in WPF datagrid. Data is loaded from .csv. I'm using .net framework 4.0.
Filepath includes the .csv characters at the end. CSV file is generated and opened by the following code.
public static void GenerateCsvTemplate(bool overwrite)
{
try
{
if (overwrite)
{
if (!File.Exists(folderPath))
{
Directory.CreateDirectory(folderPath);
}
string delimiter = Settings.Default.SplitValue.ToString();
string content = "a;b;c;d;f";
File.WriteAllText(filePath, content,UTF8Encoding.UTF8);
}
Process.Start(filePath);
}
catch (Exception ex)
{
logger.Error(ex.Message);
}
}
Creating the file in UTF-8 encoding is not changing the output of my european characters on my datagrid. According to my understanding the default encoding should be UTF-8 in WPF. Users modify the template and save it in .csv in excel. When they enter european characters they are not displayed correctly in datagrid which reads the .csv file.
Below the code when I'm reading the .csv file:
using (var reader = new StreamReader(File.OpenRead(FileHelper.filePath), UTF8Encoding.UTF8))
{
//Read file and populate objects
}
I think I'm missing something.