转义特殊字符
我下面的代码似乎正在编码特殊字符,我该如何让它转义这些字符?
str1 += myGridView.Rows[idx].Cells[2].Text + ";";
当我检查网格视图 html 源时,表格单元格文本为 = 'http://news.google.co.uk/nwshp?ie=UTF-8&hl=en&tab=wn&q=Clifford+ Chance&output=rss
'
但 str1 的值为 'http://news.google.co.uk/nwshp?ie=UTF-8&hl=en&tab= wn&q=Clifford+Chance&output=rss;
'
非常感谢,
My code below seems to be encoding special charcters how do I get it to escape these?
str1 += myGridView.Rows[idx].Cells[2].Text + ";";
When i check the grid view html source the table cell text is = 'http://news.google.co.uk/nwshp?ie=UTF-8&hl=en&tab=wn&q=Clifford+Chance&output=rss
'
But the value for str1 is 'http://news.google.co.uk/nwshp?ie=UTF-8&hl=en&tab=wn&q=Clifford+Chance&output=rss;
'
Many Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您在这里看到的是 HTML 控件将您的文本编码为 HTML,以便它像在字符串中一样显示在客户端的浏览器中。
您可以使用
HttpUtility.HtmlDecode(string)
解码 HTML 编码字符串。What you're seeing here is the HTML control encoding your text to HTML so it appears in the client's browser as it does in your string.
You can use
HttpUtility.HtmlDecode(string)
to decode an encoded string of HTML.