Using .NET how to convert ISO 8859-1 encoded text files that contain Latin-1 accented characters to UTF-8

后端 未结 2 998
迷失自我
迷失自我 2020-11-30 06:58

I am being sent text files saved in ISO 88591-1 format that contain accented characters from the Latin-1 range (as well as normal ASCII a-z, etc.). How do I convert these fi

2条回答
  •  迷失自我
    2020-11-30 07:10

    If the files are relatively small (say, ~10 megabytes), you'll only need two lines of code:

      string txt = System.IO.File.ReadAllText(inpPath, Encoding.GetEncoding("iso-8859-1"));
      System.IO.File.WriteAllText(outPath, txt);
    

提交回复
热议问题