Search code examples
ruby-on-railsencodingasset-pipelinepipelineassets

Rails 3.2.11 asset pipeline: accented characters in javascript get converted to question marks in production


I'm writing a rails application in Spanish and I'm having trouble displaying accented characters from JavaScript.

Everything works fine in development, but in production, in the unified /public/assets/application[*fingerprint*].js file, all my special Spanish characters get converted to question marks. I have triple checked that my .js files are indeed in UTF-8, and have also tried changing the extension to .js.erb and putting <%# encoding: utf-8 %> at the top of the files, but still no joy.

I created a new, simple application from scratch just to test this and the problem persists. I've even tried disabling the uglifier gem, just in case, and that didn't work either. My main suspect now is Sprockets, but can't find any information of this happening to anyone else. Has anyone encountered a similar problem?


Solution

  • OK, so I finally got it working by replacing Rhino with Node.js (I'm required to use jRuby so therubyracer was apparently not a good option either).

    ==============================================

    UPDATE: It's been quite a while and I had pretty much forgotten about this post, but now I have come across it again I feel there's something I should mention: Although my original solution of using Node.js worked, it turned out to be more of an inadverted workaround than anything else.

    As I found out some time later, the source of the problem was that, due to my lack of experience with Linux, I was pretty sure that the locale was set up properly when it wasn't at all. Once I configured my locale correctly, it fixed this and quite a few other locale-related problems I was experiencing.