Converting problem ANSI to UTF8 C#

前端 未结 7 1722
借酒劲吻你
借酒劲吻你 2021-01-17 20:08

I have a problem with converting a text file from ANSI to UTF8 in c#. I try to display the results in a browser.

So I have a this text file with many accent characte

7条回答
  •  没有蜡笔的小新
    2021-01-17 20:22

    This is probably happening because your original string text already contains invalid characters. Encoding conversion only makes sense if your input is a byte array. So, you should read the file as byte array instead of string, or, as Henk said, specify the encoding for reading the file.

提交回复
热议问题