我现在遇到一个问题,摄氏符号被读取为 C 而不是°C。
看起来像编码的罪魁祸首。我试图这样做:
using (StreamReader sr = new StreamReader(this._inFilePath,System.Text.Encoding.Unicode ,true))
代替
using (StreamReader sr = new StreamReader(this._inFilePath))
但我现在收到垃圾......原始文件编码是否必须与 StreamReader 编码匹配?我正在使用紧凑型框架 2.0。
我在网上找到了这个,但如果使用它,我已经将它全部读入一个字节数组,检测每一行的结尾,将其转换为 Unicode,然后继续执行程序逻辑。有人用过这个类吗?