William Jones
William Jones

Reputation: 18279

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

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 already have the following, but I can't tell that it does anything:

config.encoding = "utf-8"

Upvotes: 6

Views: 1362

Answers (2)

Micah
Micah

Reputation: 17798

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

Upvotes: 0

codevoice
codevoice

Reputation: 474

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

Upvotes: 4

Related Questions