c# – HttpUtility.UrlEncode标准编码与指定编码?
发布时间:2020-12-15 08:43:38 所属栏目:百科 来源:网络整理
导读:两者之间有什么区别: HttpUtility.UrlEncode("some string with é and β and stuff")HttpUtility.UrlEncode("some string with é and β and stuff",Encoding.UTF8)HttpUtility.UrlEncode( "some string with é and β and stuff",Encoding.Default )
两者之间有什么区别:
HttpUtility.UrlEncode("some string with é and β and stuff") HttpUtility.UrlEncode("some string with é and β and stuff",Encoding.UTF8) HttpUtility.UrlEncode( "some string with é and β and stuff",Encoding.Default ) 结果是: some+string+with+%c3%a9+and+%ce%b2+and+stuff some+string+with+%c3%a9+and+%ce%b2+and+stuff some+string+with+%e9+and+%df+and+stuff 在测试时,我得到前两个相同的结果,所以我可以安全地假设UTF8是默认值,除非指定,或者可以在不同的系统上有所不同吗? 我有一些unicode转义序列的示例,如下所示: %u00e9(é) 相当确定paypal在他们的IPN请求中发送了它.为什么.NET不像这样编码? 解决方法
来自Reflector的方法HttpUtility.UrlEncode Method(String)的源代码:
public static string UrlEncode(string str) { if (str == null) { return null; } return UrlEncode(str,Encoding.UTF8); } 对于你的问题:
是的你可以. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |