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"

Answers


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.


Need Your Help

How to View Android Native Code Profiling?

android android-emulator profiling qemu

I started my emulator with ./emulator -trace profile -avd emulator_15. I then tracked down the trace files to ~/.android/avd/rodgers_emulator_15.avd/traces/profile, where there are six files: qtr...

Difference between irange and counting_range in Boost

c++ boost integer range counting

What's the difference between irange and counting_range?