德code%的恩codeD字符串C#.NET [英] decode percent-encoded string c# .net

查看:162
本文介绍了德code%的恩codeD字符串C#.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何去$ 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)

这篇关于德code%的恩codeD字符串C#.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆