【发布时间】:2020-08-14 14:01:35
【问题描述】:
我需要使用UCS-2 LE BOM 编码在 FTP 服务器上上传/创建文件。我正在使用 C#。
基于Microsoft's documentation,我必须将UnicodeEncoding 与bigEndian:false 和byteOrderMark:true 一起使用。代码如下:
using (WebClient client = new WebClient())
{
client.Encoding = new UnicodeEncoding(false, true);
client.Credentials = myCredentials;
client.UploadString(path, WebRequestMethods.Ftp.UploadFile, myCsvInString);
}
FTP 服务器上创建的文件实际上有UCS-2 Little Endian。出于测试目的,我尝试将byteOrderMark 切换为false,得到了相同的结果。
为什么?我错过了什么?
我知道我可以添加'\uFEFF',但为什么不自动完成?
【问题讨论】:
标签: c# unicode encoding byte-order-mark