1

在客户端,我有一个 textarea,我像这样提取它的值:

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

然后字符串如下所示:

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

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

我怎样才能做到这一点?

4

2 回答 2

4

使用HtppUtility.UrlDecode

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

结果:

This is a test
This is a new line
于 2013-05-16T10:58:41.210 回答
1

使用 HtppUtility.UrlDecode方法

int numberOfCharacters = 
    HttpUtility.UrlDecode("This%20is%20a%20test%0AThis%20is%20a%20new%20line").Length;
于 2013-05-16T11:00:00.197 回答