Forum Discussion

Marc Roussel's avatar
Marc Roussel
Iron Contributor
Nov 29, 2021
Solved

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?

  • 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

2 Replies

  • Nikhilgoel's avatar
    Nikhilgoel
    Copper Contributor
    Try using Encoding.GetEncoding("iso-8859-1") instead of Encoding.UTF8 since Encoding.UTF8 does not have ASCII values for extended Latin charcaters
    • Marc Roussel's avatar
      Marc Roussel
      Iron 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.

      Thanx

Resources