在 C# 中将文件另存为 Unicode 停止按预期工作
我有一个解决方案,将该文件转换为 Unicode(此转换是必要的,以便 MS Excel 正确显示数据):
string fileContent = File.ReadAllText(inputFilePath, Encoding.Default);
File.WriteAllText(outputFilePath, fileContent, Encoding.Unicode);
它在很长一段时间内工作正常,但突然停止工作。目前转换后数据显示为垃圾:
我注意到数据现在保存为 UTF-16 LE。有什么想法导致这个问题吗?
I have demo file Encoded UTF-8, which includes special characters:
I had solution which was converting this file to Unicode (This conversion is necessary so data was displayed by MS Excel correctly):
string fileContent = File.ReadAllText(inputFilePath, Encoding.Default);
File.WriteAllText(outputFilePath, fileContent, Encoding.Unicode);
It worked just fine for a long time, but suddenly it stopped working. Currently after conversion data is displayed rubbish:
I've noticed that data is saved now as UTF-16 LE. Any ideas what is causing this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论