特殊字符编码不起作用? (&)
Special character encoding not working? (&)
我试过像这样 &
对 &
进行编码。但是,当我尝试这样做时,它并没有像我在 Whosebug 上阅读它时那样在我的标题中修复它。需要说明的是,我的页面标题在浏览器中仍然显示 Plan & Billing
,而在我的代码中我有 Plan & Billing
。为什么编码不起作用? (p.s。它适用于其他特殊字符)
HTML:
<% page_title 'Plan & Billing • My Account' %>
这个问题对于我发现的任何其他问题都是独一无二的,因为我问的是 "Why my encoding is not working",而建议的重复项只说 "Why you need them for encoding"。
如评论中所述,您的字符串应设为 html_safe
:
<% page_title 'Plan & Billing • My Account'.html_safe %>
您也可以使用sanitize
方法:
<% page_title sanitize('Plan & Billing • My Account') %>
我试过像这样 &
对 &
进行编码。但是,当我尝试这样做时,它并没有像我在 Whosebug 上阅读它时那样在我的标题中修复它。需要说明的是,我的页面标题在浏览器中仍然显示 Plan & Billing
,而在我的代码中我有 Plan & Billing
。为什么编码不起作用? (p.s。它适用于其他特殊字符)
HTML:
<% page_title 'Plan & Billing • My Account' %>
这个问题对于我发现的任何其他问题都是独一无二的,因为我问的是 "Why my encoding is not working",而建议的重复项只说 "Why you need them for encoding"。
如评论中所述,您的字符串应设为 html_safe
:
<% page_title 'Plan & Billing • My Account'.html_safe %>
您也可以使用sanitize
方法:
<% page_title sanitize('Plan & Billing • My Account') %>