开发者

Rails/Ruby 1.9: Is there a better way to put Unicode in source files than sticking # encoding at the top of every file

开发者 https://www.devze.com 2023-01-31 01:37 出处:网络
I just upgraded to Rails 3 and Ruby 1.9. All of my source files that used Unicode inside of them (such as emdashes) caused problems until I found out that you now need to include the following magic c

I just upgraded to Rails 3 and Ruby 1.9. All of my source files that used Unicode inside of them (such as emdashes) caused problems until I found out that you now need to include the following magic comment on top of each source file:

# encoding: utf-8

Is there a better way to do this? It'd be nice if it just automatically treated every source file as utf-8 like Rails 2.3/Ruby 1.8 did, and I don't see any apparent disadvantage from doing so.

In my application.rb I alre开发者_如何学Cady have the following, but I can't tell that it does anything:

config.encoding = "utf-8"


i found only rake check_encoding_headers it add the magic comment to all files.


There is also a gem for adding encodings to all headers.

0

精彩评论

暂无评论...
验证码 换一张
取 消