SOLVED

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

%3CLINGO-SUB%20id%3D%22lingo-sub-3012844%22%20slang%3D%22en-US%22%3EI'm%20having%20a%20web%20app%20in%20Blazor%20Wasm%20ASP.NET%20Core%20server.%20There%20seem%20to%20be%20an%20issue%20with%20.NET%206%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3012844%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20a%20file%20encoded%20in%20UTF8%20thus%20having%20French%20special%20characters%20like%20%C3%A9%2C%20%C3%A8%20or%20%C3%AA%20etc...%3C%2FP%3E%3CP%3EWhen%20I%20read%20the%20file%20using%26nbsp%3BSystem.IO.File.ReadAllText(MyPathFileName%2C%20Encoding.UTF8)%3CBR%20%2F%3E%3CBR%20%2F%3EI%20still%20get%20the%20file%20with%20the%20wrong%20format%2C%20here's%20a%20single%20line%20for%20instance%20%3A%3CBR%20%2F%3E%22Name%22%3A%20%22%EF%BF%BDric%20S%EF%BF%BDguin%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20idea%20what%20I'm%20doing%20wrong%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3012844%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3E.Net%20Core%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Contributor

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)
Solution
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.

Thanx