How to use utf-8 encoded data in erb template

后端 未结 4 727
盖世英雄少女心
盖世英雄少女心 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-20 23:56

    If you're using Rails, have you configured default encoding, in application.rb? like:

    config.encoding = "utf-8"
    

    My Rails (3.2.1) project does not contain any configuration other than that.

    Other thing you want to check is, whether your datafile really in UTF-8 or not. If you're using Unix-like system, you can use 'nkf' command to check the code, by:

    nkf --guess FILE_NAME
    

提交回复
热议问题