Ruby on Rails - £ sign troubles

2019-02-19 06:36发布

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?

3条回答
你好瞎i
2楼-- · 2019-02-19 06:48

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).

查看更多
甜甜的少女心
3楼-- · 2019-02-19 06:55

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

查看更多
Fickle 薄情
4楼-- · 2019-02-19 07:03

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
查看更多
登录 后发表回答