Forum: Ruby on Rails rails cant display £

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
7a666449acc7e18a7002bc88798a44d3?d=identicon&s=25 Jon (Guest)
on 2007-03-01 15:59
Hi, under webrick the character, £, displays fine. Under apache it has
some problems.

The £ displays fine on my administrator page, using the default
generated code:

<% for column in Product.content_columns %>
  <b><%= column.human_name %>:</b> <%=h @product.send( %>
<% end %>

but when i construct my own view, and use:

<p><%= @product.price_prefix %><%= sprintf("%0.2f",@product.price)

the £ displays as ablack diamond and white question mark.

Whats that all about?
7507046367703e4ec75293ee42ef6915?d=identicon&s=25 Andrew France (Guest)
on 2007-03-01 17:14
(Received via mailing list)
> the £ displays as ablack diamond and white question mark.
> Whats that all about?

The pound sign should be the character entity: &pound;

Various page encodings will probably mess with it in different ways

7a666449acc7e18a7002bc88798a44d3?d=identicon&s=25 Jon (Guest)
on 2007-03-01 17:33
Thanks andrew, unfortunatly this is user entered content, i feel its not
reasonable to ask them to enter &pound.

But i dont understand how it can be displayed correctly, and incorrectly
on the same site, rails is doing something different when it renders
these views.
5a16c9ccbb3c8e9fa1839f85d05a1cf8?d=identicon&s=25 Jorge Sousa (Guest)
on 2007-03-01 19:22
(Received via mailing list)
Try put an 'H' when you output ruby code, eg:

  <%=h @product.price_prefix %>
  <%=h sprintf("%0.2f",@product.price)%>

<%=h CONTENT %>

will escape things for you.


On 3/1/07, Jon <> wrote:
> Posted via
> >

Jorge Sousa
7a666449acc7e18a7002bc88798a44d3?d=identicon&s=25 Jon (Guest)
on 2007-03-01 21:33
Thanks Jorge, unfortunately it had no effect.
This topic is locked and can not be replied to.