c# - 解码百分比编码的字符串 c# .net

标签 c# .net

如何解码如下字符串:

name1=ABC&userId=DEF&name2=zyx&payload=%3cSTAT+xmlns%3axsi%3d%22http%3a%2f%2fwww.w3.org%2f2001%2fXMLSchema-instance%22%3e%3cREQ...

背景:我正在接受 HTTP POST(基本上是名称值对),然后将字节数组转换为字符串:

Encoding.UTF8.GetString(response, 0, response.Length);

我已经尝试了 WebUtility 和 HttpUtility 的 HtmlDecode 方法,但似乎得到了相同的字符串。

最佳答案

这应该为您完成工作:

System.Uri.UnescapeDataString(str)

关于c# - 解码百分比编码的字符串 c# .net,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12898556/

相关文章:

c# - 旋转渐变在 WPF 中脱离 Canvas

c# - 部署后 Appsetting.json 无法与 Azure 函数应用一起使用

c# - 使用数据注释的 WPF MVVM 验证

c# - 各种对象的可重复逻辑

c# - Web 服务和轮询

c# - 来自网络服务 : method not allowed 的响应

c# - TCP 套接字/NetworkStream 意外失败

c# - 使用 using 指令在 C# 中缩短带有别名的枚举声明

c# - 合并两个列表列表

c# - .NET 4 Parallel.ForEach 和 PLINQ : can they overwhelm the thread pool and kill the app performance?