c# - 计算 URI 编码字符串中的实际字符

标签 c#

在客户端,我有一个文本区域,我像这样提取它的值:

var TheURIEncodedString = encodeURI($('#TheTextArea').val());

字符串看起来像这样:

"This%20is%20a%20test%0AThis%20is%20a%20new%20line"

我通过 ajax 发送这个字符串,当我在服务器上接收到它时,我需要计算实际字符的数量,而不是字符串的长度。

我该怎么做?

最佳答案

使用HtppUtility.UrlDecode :

HttpUtility.UrlDecode("This%20is%20a%20test%0AThis%20is%20a%20new%20line").Length;

结果:

This is a test
This is a new line

关于c# - 计算 URI 编码字符串中的实际字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16585556/

相关文章:

c# - 从 IMG 标签中查找 src 的正则表达式

c# - ASP.NET MVC Razor : How to render a Razor Partial View's HTML inside the controller action

C# xml 阅读器,相同的元素名称

c# - Visual Studio 分析 .psess 不存在或无效

c# - 澄清 ColorMatrix 转换的工作原理

c# - 计算字符串中数组中字符的出现次数?

c# - 如何将字符串编号拆分为单独的整数

c# - SSL 证书不起作用

c# - 使用 Entity Framework T4 POCO

c# - 可以根据字符串名称加载枚举吗?