德code%的恩codeD字符串C#.NET字符串、code、codeD、NET

2023-09-03 03:50:05 作者:一个亾溡想起沵

我如何去$ C像下面$ CA字符串:

How do I decode a string like the following:

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

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(名称值对,基本上),然后将字节数组转换为字符串:

Background: I'm accepting an HTTP POST (name value pairs, basically) then converting the byte array to string with:

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

我已经试过WebUtility的HtmlDe code方法和HttpUtility但似乎得到相同的字符串返回。

I've tried the HtmlDecode method of WebUtility and HttpUtility but appear to get the same string back.

推荐答案

这应该做的工作适合你:

This should do the job for you:

System.Uri.UnescapeDataString(str)