I'm having a web app in Blazor Wasm ASP.NET Core server. There seem to be an issue with .NET 6


I have a file encoded in UTF8 thus having French special characters like é, è or ê etc...

When I read the file using System.IO.File.ReadAllText(MyPathFileName, Encoding.UTF8)

I still get the file with the wrong format, here's a single line for instance :
"Name": "�ric S�guin"


Any idea what I'm doing wrong?

2 Replies
Try using Encoding.GetEncoding("iso-8859-1") instead of Encoding.UTF8 since Encoding.UTF8 does not have ASCII values for extended Latin charcaters
best response confirmed by Marc Roussel (Contributor)
Solved. The problem was because the file wasn't saved in UTF8. After saving the file in UTF8 I've been able to use Encoding.UTF8.