- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
"-_.!~*'()" Uri-6ren">
为什么 EscapeDataString 在 .NET 4 和 4.5 之间的行为不同?输出是
Uri.EscapeDataString("-_.!~*'()") => "-_.!~*'()"
Uri.EscapeDataString("-_.!~*'()") => "-_.%21~%2A%27%28%29"
By default, the EscapeDataString method converts all characters except for RFC 2396 unreserved characters to their hexadecimal representation. If International Resource Identifiers (IRIs) or Internationalized Domain Name (IDN) parsing is enabled, the EscapeDataString method converts all characters, except for RFC 3986 unreserved characters, to their hexadecimal representation. All Unicode characters are converted to UTF-8 format before being escaped.
供引用,非保留字符定义如下RFC 2396 :
unreserved = alphanum | mark
mark = "-" | "_" | "." | "!" | "~" | "*" | "'" |
(" | ")"
并且在 RFC 3986 :
ALPHA / DIGIT / "-" / "." / "_" / "~"
EscapeDataString的每个字符是否转义貌似大概是这样判断的
is unicode above \x7F
? PERCENT ENCODE
: is a percent symbol
? is an escape char
? LEAVE ALONE
: PERCENT ENCODE
: is a forced character
? PERCENT ENCODE
: is an unreserved character
? PERCENT ENCODE
在 RFC2396 和 RFC3986 之间做出选择的最后检查“是一个未保留的字符”。方法源码一字不差
internal static unsafe bool IsUnreserved(char c)
{
if (Uri.IsAsciiLetterOrDigit(c))
{
return true;
}
if (UriParser.ShouldUseLegacyV2Quirks)
{
return (RFC2396UnreservedMarks.IndexOf(c) >= 0);
}
return (RFC3986UnreservedMarks.IndexOf(c) >= 0);
}
那个代码指的是
private static readonly UriQuirksVersion s_QuirksVersion =
(BinaryCompatibility.TargetsAtLeast_Desktop_V4_5
// || BinaryCompatibility.TargetsAtLeast_Silverlight_V6
// || BinaryCompatibility.TargetsAtLeast_Phone_V8_0
) ? UriQuirksVersion.V3 : UriQuirksVersion.V2;
internal static bool ShouldUseLegacyV2Quirks {
get {
return s_QuirksVersion <= UriQuirksVersion.V2;
}
}
文档说 EscapeDataString 的输出取决于是否启用 IRI/IDN 解析,而源代码说输出由 TargetsAtLeast_Desktop_V4_5
的值决定,这似乎自相矛盾。有人可以解决这个问题吗?
最佳答案
与 4.0 相比,4.5 在系统功能和行为方面做了很多更改。你可以看看这个线程
或
你可以直接到下面的链接
http://msdn.microsoft.com/en-us/library/hh367887(v=vs.110).aspx
所有这一切都来自世界各地用户的意见。
关于c# - Uri.EscapeDataString 怪异,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24962514/
我不明白为什么有两段代码要做完全相同的事情,却在 Scala 中做不同的事情。 第一个例子: scala> val ggg = Source.fromFile("/somefile"); ggg: s
您认为以下结果如何? SELECT CHARINDEX('space and /* comment */', 'Phrase with space and /* comment */') AS Mat
我正在尝试为单元测试创建带有某些修饰符的 MouseEvent。我使用的是 J2SE,以下代码无法通过: public void testMouseEventProblem() { Mouse
为什么输出0而不是1? System.out.println((int) (Math.ceil(1/2))); 虽然这个正确输出 1 System.out.println((int) (Math.ce
如果我运行这段代码: var a = new Float32Array(3); a[0] = 1; a[1] = 1.1; a[2] = 1.00001; 我得到了a的结果: [1, 1.100000
今天刚开始使用“UIRefreshControl”,发现了一些奇怪的事情。 如果我在 InterfaceBuilder 中创建了 UIRefreshControl,并将其连接起来,我的选择器将永远不会
这是一个非常简单的问题,但是 PHP 文档没有解释为什么会这样。 我有这个代码: var_dump($newattributes); var_dump($oldattributes); var_dum
如果我通常加载一个 UITabBarController 并在 View 之间切换,它会调用每个 View Controller 的 viewWillAppear。但事实并非如此。 我想在触摸另一个标
我有一个关于 setContentOffset 的奇怪问题,我似乎无法解决:我正在尝试构建一个“无尽”的 ScrollView ,所以我想在某个位置重置内容偏移量。使用下面的代码,setContent
这个把我难住了。 我有一个 java.sql.ResultSet,我正在从中提取字符串值,如下所示: address.setAddressLine1(rs.getString("AddressLine
...至少对我来说。这段代码曾经工作得很好。我很确定什么都没有改变,但现在突然间它的行为变得奇怪了。基本上我正在尝试创建内联编辑功能。当用户单击该链接时,它会动态生成一个文本框以及一个确认和取消链接。
我在 ldd 中遇到了以下奇怪的情况 $ sudo ldd ./monit not a dynamic executable $ readelf -d monit Dynamic sectio
我的 app.config 文件发生了一件奇怪的事情。我的 ConnectionStrings 部分包含以下内容: 但是,当我通过 ConfigurationManager.Connecti
CSS 不是我的强项,我不确定我的列表项在 IE6 中发生了什么。我希望它们垂直对齐,但第一个列表项总是被向右推一两个像素,因此它不再与列表中的其他成员对齐。就我而言,此列表在 IE7/8、FF3 和
制作了一个网络作品集。我的名字周围有联系方式。文本的初始宽度为 0,当鼠标悬停时,图标会随着“过渡”属性展开。左边的图标工作正常,但右边的图标过渡很奇怪,尤其是手机。 http://jsfiddle.
发生的事情是我遵循了这个demo ,我修改了它以满足我的需要,让它工作,将其更改为使用函数绘制两个图形,但现在使用 plt.show() 或 plt 根本不起作用。 savefig() 这是我的代码
我正在尝试编写一个从整数中提取最低阶数的函数。例如: > 24689.lowest_order => 9 到目前为止我有: class Integer def lowest_order I
不确定这是包中的错误还是由于其他原因,但我们开始吧。 我正在使用以下包在相似性分数的对称矩阵(大小为 10x10)上查找最大特征值及其对应的特征向量: scipy.sparse.linalg.eige
我正在尝试实现一个名为“inet_pton”的函数,它将 IPv4 或 IPv6 的字符串表示形式(如“66.102.1.147”[google])转换为二进制网络字节有序形式。这是我的代码的相关部分
比较 float 。根据第一个代码块,5 大于 37.66。第二个 block 声称 5 小于 37.66。 toFixed() 对这些使第一个 block 按照它的方式使用react的是什么? (这
我是一名优秀的程序员,十分优秀!