Ruby on Rails - £ sign troubles

2019-02-19 06:17发布

问题:

I have <%= f.label :cost, "Cost (£/m)" %> in a form. When the form is rendered the "£" sign comes out as �. I am using utf-8 encoding. Why is this happening?

回答1:

Suggestion from my experience) :

  1. verify that your file erb is saved in utf-8
  2. I recomend you to use number_to_currency method


回答2:

Are you outputting HTML? If so you need to escape the character <%= f.label :cost, "Cost (&pound;/m)" %>



回答3:

Either send your page with UFT-8 encoding, or send the pound sign as &pound; (or &#163; if you're sending XML rather than HTML).