I have a Rails (version 3.2.1) project and I recently switched from Ruby 1.8.7 to Ruby 1.9.3. I added encoding comments in all .rb
and .erb
files but I have a problem with plain .js
JavaScript assets. They contain comments in Polish saved with UTF-8 encoding. In most files it works fine - Ruby detects the encoding correctly - but in one file I have only a single UTF-8 character ś
in a comment line. And now the Rails server fails with Encoding::CompatibilityError
when displaying index page (which doesn't even reference the JavaScript file).
I know it's a problem with Ruby's automatic encoding detection as it probably can't detect encoding from single character outside ASCII range, but it's very frustrating since it shouldn't matter anyway - the file is only linked to as an asset.
My question is: how to enforce UTF-8 encoding in all .js
assets?