documentcloud / jammit

Industrial Strength Asset Packaging for Rails
http://documentcloud.github.com/jammit/
MIT License
1.16k stars 197 forks source link

Character encoding in template #81

Closed mikz closed 13 years ago

mikz commented 13 years ago

Hi, I just wanted to start using templates, but I've run into this issue:

    /Users/mikz/.rvm/gems/ruby-1.9.2-p0@avion-is/gems/jammit-0.5.3/lib/jammit/compressor.rb:70:in `compress_js': incompatible character encodings: UTF-8 and ASCII-8BIT (Encoding::CompatibilityError)
from /Users/mikz/.rvm/gems/ruby-1.9.2-p0@avion-is/gems/jammit-0.5.3/lib/jammit/packager.rb:82:in `pack_javascripts'
from /Users/mikz/.rvm/gems/ruby-1.9.2-p0@avion-is/gems/jammit-0.5.3/lib/jammit/packager.rb:40:in `block in precache_all'
from /Users/mikz/.rvm/gems/ruby-1.9.2-p0@avion-is/gems/jammit-0.5.3/lib/jammit/packager.rb:40:in `each'
from /Users/mikz/.rvm/gems/ruby-1.9.2-p0@avion-is/gems/jammit-0.5.3/lib/jammit/packager.rb:40:in `precache_all'
from /Users/mikz/.rvm/gems/ruby-1.9.2-p0@avion-is/gems/jammit-0.5.3/lib/jammit/command_line.rb:31:in `initialize'
from /Users/mikz/.rvm/gems/ruby-1.9.2-p0@avion-is/gems/jammit-0.5.3/bin/jammit:5:in `new'
from /Users/mikz/.rvm/gems/ruby-1.9.2-p0@avion-is/gems/jammit-0.5.3/bin/jammit:5:in `<top (required)>'
from /Users/mikz/.rvm/gems/ruby-1.9.2-p0@avion-is/bin/jammit:22:in `load'
from /Users/mikz/.rvm/gems/ruby-1.9.2-p0@avion-is/bin/jammit:22:in `<main>'

when I've got non ascii characters in my template. Can anyone confirm this?

using closure compiler

mikz commented 13 years ago

problem is in Jammit Compressor concatenate method it should treat files as binary like other methods

jashkenas commented 13 years ago

Why did you close the ticket then? Is this still a problem?

mikz commented 13 years ago

I've closed ticket? I haven't noticed that. Sry. Yes it's problem. When you have UTF8 javascripts and js templates it throws encoding error because javascripts have UTF-8 encoding and templates ASCII-8BIT. I believe that concatenate method should use binary encoding like other methods do.

jashkenas commented 13 years ago

I merged in your patch -- thanks for putting it together.