Set UTF-8 as default for Ruby 1.9.3

前端 未结 4 1158
孤独总比滥情好
孤独总比滥情好 2020-12-05 20:01

I\'m on Rails 4 and Ruby 1.9.3

I use \"strange\" characters very often, so I have to declare UTF-8 encoding at the top of all .rb files.

Is there any way to

4条回答
  •  醉话见心
    2020-12-05 20:26

    I think you would want one of the following, depending on the context.

    Encoding.default_internal = Encoding::UTF_8
    Encoding.default_external = Encoding::UTF_8
    

    This setting is made in the environment.rb file.

提交回复
热议问题