£ Troubles

I have <%= f.label :cost, "Cost (&pound;/m)" %> in a file
_form.html.erb. When the form is rendered instead of getting "£" I
just get "&pound;" being rendered. I am using utf-8 encoding. Why is
this happening?

If you're on a version of rails that has the automatic xss stuff
enabled you should call html_safe on that string, or rails will pass
it through h for you

Fred

Bill Morrison wrote in post #960534:

I have <%= f.label :cost, "Cost (&pound;/m)" %> in a file
_form.html.erb. When the form is rendered instead of getting "" I
just get "&pound;" being rendered. I am using utf-8 encoding. Why is
this happening?

Are you using Rails 3, by any chance? If so, then strings get
HTML-escaped by default. Either use the literal £ character (probably
the best choice) or mark the string as raw.

In general, except for &lt;, &gt;, &amp;, and maybe &nbsp;, there's
little reason to use &entities in HTML files these days.

Best,

Thanks very much.