如何将ISO-8859-1转中文

Dear200892 2021-04-20 10:27:55
获取文件信息,发现有中文名称的文件,会出现乱码。
发现_httpWebResponse的CharacterSet是ISO-8859-1
中文都变乱码,不知道如何转换UTF-8或GB2312



HttpWebRequest _httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(Url);
_httpWebRequest.Headers.Add("Translate: f");
_httpWebRequest.Credentials = CredentialCache.DefaultCredentials;
_httpWebRequest.Method = "PROPFIND";
_httpWebRequest.Headers.Add("Depth: infinity");
HttpWebResponse _httpWebResponse = (HttpWebResponse)_httpWebRequest.GetResponse();
StreamReader _streamReader = new StreamReader(_httpWebResponse.GetResponseStream(), Encoding.GetEncoding("utf-8"));

...全文
441 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Dear200892 2021-04-21
  • 打赏
  • 举报
回复
引用 2 楼 第27个Bug 的回复:
这是URL编码了,解码下就好了
System.Web.HttpUtility.UrlDecode("http://localhost:416/%E6%96%B0%E5%BB%BA%E6%96%87%E6%9C%AC%E6%96%87%E6%A1%A3.txt")
System.Web.HttpUtility 这个是什么版本的,我现在用4.0。 还是说需要下载dll
键盘敲出字 2021-04-21
  • 打赏
  • 举报
回复
这是URL编码了,解码下就好了
System.Web.HttpUtility.UrlDecode("http://localhost:416/%E6%96%B0%E5%BB%BA%E6%96%87%E6%9C%AC%E6%96%87%E6%A1%A3.txt")
Dear200892 2021-04-21
  • 打赏
  • 举报
回复
http://localhost:416/%E6%96%B0%E5%BB%BA%E6%96%87%E6%9C%AC%E6%96%87%E6%A1%A3.txt: Name:新建文本文档.txt IsFolder:False Value:http://localhost:416/%E6%96%B0%E5%BB%BA%E6%96%87%E6%9C%AC%E6%96%87%E6%A1%A3.txt LastModified:2021/4/19 15:24:36 应该是http://localhost:416/新建文本文档.txt
Dear200892 2021-04-21
  • 打赏
  • 举报
回复
添加引用
System.Web.dll

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧