Invalid characters in File.ReadAllText

后端 未结 4 664
离开以前
离开以前 2020-12-06 17:52

I\'m calling File.ReadAllText() in a program designed to format some files that I have.

Some of these files contain the ® (174) symbol. H

4条回答
  •  执念已碎
    2020-12-06 18:28

    This is likely due to a mismatch in the Encoding. Use the ReadAllText overload which allows you to specify the proper Encoding to use when reading the file.

    The default overload will assume UTF-8 unless it can detect UTF-32. Any other encoding will come through incorrectly.

提交回复
热议问题