如何编码字符串(编码url) [英] How to encode string (encode url)
本文介绍了如何编码字符串(编码url)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个像
这样的字符串
I have a string like
select * from Contacts where lastname=''test'';
当我从php使用urlencode方法时,我得到一个结果
when I''m use urlencode method from php, i get a result
select+%2A+from+Contacts+where+lastname%3D%27test%27%3B
我的问题是,我已经尝试过使用C#做同样的事情
My question is, how to do the same thing with C#, i have tried
HttpUtility.UrlEncode("select * from Contacts where lastname=''test'';", Encoding.ASCII)
HttpUtility.UrlEncode("select * from Contacts where lastname=''test'';")
结果是
and the result is
select+*+from+Contacts+where+lastname%3d%27test%27%3b
它不能编码字符*
it can not encode character *
推荐答案
您是否尝试过HttpUtility.UrlEncode(...)
(无第二个参数)
Have you tried just HttpUtility.UrlEncode(...)
(no second parameter)
这篇关于如何编码字符串(编码url)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文