对编码内容多次UrlDecode,并不会影响最终结果。

尝试阅读了微软的源代码,不过不容易读懂。

网址:https://referencesource.microsoft.com/#System/net/System/Net/WebUtility.cs,73c04b8a4fde5039

以下为从网址上复制下来的一些关键代码,不过没看懂。

public static string UrlDecode(string encodedValue)
{
if (encodedValue == null)
return null; return UrlDecodeInternal(encodedValue, Encoding.UTF8);
}
private static string UrlDecodeInternal(string value, Encoding encoding)
{
if (value == null)
{
return null;
} int count = value.Length;
UrlDecoder helper = new UrlDecoder(count, encoding); // go through the string's chars collapsing %XX and
// appending each char as char, with exception of %XX constructs
// that are appended as bytes for (int pos = ; pos < count; pos++)
{
char ch = value[pos]; if (ch == '+')
{
ch = ' ';
}
else if (ch == '%' && pos < count - )
{
int h1 = HexToInt(value[pos + ]);
int h2 = HexToInt(value[pos + ]); if (h1 >= && h2 >= )
{ // valid 2 hex chars
byte b = (byte)((h1 << ) | h2);
pos += ; // don't add as char
helper.AddByte(b);
continue;
}
} if ((ch & 0xFF80) == )
helper.AddByte((byte)ch); // 7 bit have to go as bytes because of Unicode
else
helper.AddChar(ch);
} return helper.GetString();
}
 internal void AddChar(char ch)
{
if (_numBytes > )
FlushBytes(); _charBuffer[_numChars++] = ch;
}
  internal void AddByte(byte b)
{
if (_byteBuffer == null)
_byteBuffer = new byte[_bufferSize]; _byteBuffer[_numBytes++] = b;
}
 internal String GetString()
{
if (_numBytes > )
FlushBytes(); if (_numChars > )
return new String(_charBuffer, , _numChars);
else
return String.Empty;
}
String(_charBuffer, 0, _numChars);是看不到源代码的,到这里已经变成一行看不懂的代码
        // Creates a new string from the characters in a subarray.  The new string will
// be created from the characters in value between startIndex and
// startIndex + length - 1.
//
[System.Security.SecuritySafeCritical] // auto-generated
[ResourceExposure(ResourceScope.None)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern String(char [] value, int startIndex, int length);

下一步应该怎么办,只能希望某个大牛指点下了……

 

对编码内容多次UrlDecode的更多相关文章

  1. python中Url链接编码处理(urlencode,urldecode)

    做完了flask-web应用,这几天想用爬虫做个好玩的电影链接整合器,平时找电影都是在dytt或者dy2018之类的网站,在用dytt搜索电影<美国队长时>,发现他的搜索链接是这样的:ht ...

  2. python2与python3 字符问题以及 字符编码 内容总结

    python2与python3默认编码: python2:gbk                   print( u'上' )     操作系统也是 gbk    python3:unicode p ...

  3. 20140115-URL编码与解码

    UrlEncode()方法,有两个类都有这个方法即HttpUtility.UrlEncode和Server.UrlEncode 区别: 1.HttpUtility.UrlEncode,HttpUtil ...

  4. 百度ueditor新增的将word内容导入到富文本编辑框的功能.

    如何做到 ueditor批量上传word图片? 1.前端引用代码 <!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN& ...

  5. UEditor可以如何直接复制word的图文内容到编辑器中

    如何做到 ueditor批量上传word图片? 1.前端引用代码 <!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN& ...

  6. URLEncode和URLDecode

    URLEncode.encode(String s,String utf-8) 编码 URLDEcode.decode(String %2b%,String utf-8) 解码 用法: String ...

  7. 【字符编码】Java字符编码详细解答及问题探讨

    一.前言 继上一篇写完字节编码内容后,现在分析在Java中各字符编码的问题,并且由这个问题,也引出了一个更有意思的问题,笔者也还没有找到这个问题的答案.也希望各位园友指点指点. 二.Java字符编码 ...

  8. 中文乱码?不,是 HTML 实体编码!

    When question comes 在 如何用 Nodejs 分析一个简单页面 一文中,我们爬取了博客园首页的 20 篇文章标题,输出部分拼接了一个字符串: var $ = cheerio.loa ...

  9. 各种url编码

    URLENCODE和URLDECODE是比较常用的URL参数转换方法,为以后使用方便,自己归类一下.   一.JavaScript: 编码:encodeURIComponent(URIString)  ...

随机推荐

  1. jquery头像上传剪裁插件cropper的前后台demo

    因为一个项目要做一个头像上传的功能,因此选择了使用jquery的头像插件cropper,cropper是一款使用简单且功能强大的图片剪裁jQuery插件,但是在使用的时候,有一个很大的坑需要注意,那就 ...

  2. Linux中Zookeeper部署和集群部署

    自己网上下载安装包,我下载的是tar.gz安装包直接解压,也可以下载rpm格式 1.下载zookeeper安装包,放到/usr/local/zookeeper安装包网上下载 2.解压文件tar -zx ...

  3. PHP留言板的实现思路

    本文实例为大家分享了php留言板的实现思路,供大家参考,具体内容如下:1.创建一个存放留言信息的文件名2.获取表单中的数据给一个变量3.判断文件的时候存在4.对文件执行写的操作,在这之前,注意打开文件 ...

  4. Appointment Helper

    using System; using Microsoft.Xrm.Sdk; using Microsoft.Crm.Sdk.Messages; using Microsoft.Xrm.Sdk.Que ...

  5. MapWinGIS使用

    .net语言中使用MapWinGIS.ocx http://www.cnblogs.com/kekec/archive/2011/03/30/1999709.html 基于MapWinGis的开发探索 ...

  6. 搭建简单Django服务并通过HttpRequester实现GET/POST http请求提交表单

    调试Django框架写的服务时,需要模拟客户端发送POST请求,然而浏览器只能模拟简单的GET请求(将参数写在url内),网上搜索得到了HttpRequester这一firefox插件,完美的实现了模 ...

  7. 优步UBER司机全国各地奖励政策汇总 (2月29日-3月6日)

    滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...

  8. day 5 模块发布安装

    1.模块的位置 现在当前路径查找,再到系统路径/usr/lib/python3.5/查找,再到其他系统路径查找 2.模块发布 1)模块目录结构 Msg ├── __init__.py ├── recv ...

  9. hive 更改列的位置时遇到的问题

    hive > desc formatted tb_fq; OK col_name data_type comment # col_name data_type comment name stri ...

  10. mysql c 获取error_code

    #include <stdio.h> #include <mysql.h> int main(int argc, char **argv) { MYSQL *con = mys ...