在客户端上,我有一个textarea,我提取它的值如下:
var TheURIEncodedString = encodeURI($('#TheTextArea').val());
然后字符串如下所示:
"This%20is%20a%20test%0AThis%20is%20a%20new%20line"
我通过ajax发送这个字符串,当我在服务器上收到它时,我需要计算实际字符的数量,而不是字符串的长度。
我该怎么做?
答案 0 :(得分:4)
HttpUtility.UrlDecode("This%20is%20a%20test%0AThis%20is%20a%20new%20line").Length;
结果:
This is a test
This is a new line
答案 1 :(得分:1)
int numberOfCharacters =
HttpUtility.UrlDecode("This%20is%20a%20test%0AThis%20is%20a%20new%20line").Length;