How to use utf-8 encoded data in erb template

后端 未结 4 730
盖世英雄少女心
盖世英雄少女心 2021-01-20 23:38

I have an data-file stored with utf-8 encode, and I want to embed the data to an erb template. The data-file is explicitly encoded with utf-8 at the top. But while

4条回答
  •  再見小時候
    2021-01-21 00:12

    In the scenario where you have an ERB template rendering strings from another file that is in UTF-8, adding the following to the top of the ERB template solved it for me:

    <%# coding: UTF-8 %>
    

    (instead of <% # -*- coding: UTF-8 -*- %>)

提交回复
热议问题