[英]Encode two double quotation marks in ruby
I have following string saved in database:我在数据库中保存了以下字符串:
<p>ampersand (&), bracket(<>), quotation marks (""'')</p>\r\n
I need to encode the special symbols and get a string我需要对特殊符号进行编码并得到一个字符串
<p>ampersand (&), bracket(<>), quotation marks (""'')</p>
I used CGI library to encoding:我使用 CGI 库进行编码:
CGI::unescapeHTML("<p>ampersand (&), bracket(<>), quotation marks (""'')</p>\r\n")
the method returns "<p>ampersand (&), bracket(<>), quotation marks (\"\"'')</p>\r\n"
该方法返回"<p>ampersand (&), bracket(<>), quotation marks (\"\"'')</p>\r\n"
but should be但应该是
<p>ampersand (&), bracket(<>), quotation marks (""'')</p>
It's actually correct (the method).它实际上是正确的(方法)。 It's returning what you want.它正在返回您想要的。
The \
you are seeing before the double quotes are just artifacts of rendering a string with embedded double quotes, so that they're not interpreted as the end of the string.您在双引号之前看到的\
只是渲染带有嵌入双引号的字符串的工件,因此它们不会被解释为字符串的结尾。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.