对编码内容多次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. Python中常见的字典dict处理

    #字典的赋值d = [{"dasda": 123, "gsgsg": 3344}, {"dasdz": 123, "gsksg&q ...

  2. ACM1003:Max Sum

    Problem Description Given a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum ...

  3. python 感叹号的作用

    1.     !表示反转逻辑表达式的值 2.      打印格式控制中: x!r代表repr(x),x!s代表str(x),x!a代表ascii(x)

  4. 22-Consent 确认逻辑实现

    1-定义一个从前台传到后台的viewModel namespace MvcCookieAuthSample.Models { public class InputConsentViewModel { ...

  5. Java设计模式(3)——创建型模式之抽象工厂模式(Abstract Factory)

    一.概述 抽象工厂模式是指当有多个抽象角色时,使用的一种工厂模式.抽象工厂模式可以向客户端提供一个接口,使客户端在不必指定产品的具体情况下,创建多个产品族中的产品对象. UML图: 其他的过多概念不再 ...

  6. 北京Uber优步司机奖励政策(3月26日)

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

  7. python字符串格式化符号及转移字符含义

    博文出自鱼C论坛文章 http://bbs.fishc.com/thread-39140-1-1.html

  8. 海思NB-IOT死机问题解决记录

    1. 首先抓下LOG的信息,这个应该是MCU到NB的数据 2. 看下NB到MCU的数据 3. 总结起来,只看到了NB模块的启动,似乎AT指令,肯本没收到.测试中确实出现了复位,但是不清楚是发送的AT指 ...

  9. DSP5509的XF实验-第一篇

    1. 使用大道科技的EASY-DSP5509开发板,测试第一个例程,DSP_easy5509\Code-Easy5509\EX01_XF\XF 2. 直接编译,报出错误,在Problems窗口错误指示 ...

  10. Odd CSS syntax. [class^='icon-'], [class*=' icon-']

    原文: https://stackoverflow.com/questions/20322740/odd-css-syntax-class-icon-class-icon I am going thr ...