documentcloud / jammit

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

Encoding::UndefinedConversionError #116

Closed volkanunsal closed 13 years ago

volkanunsal commented 13 years ago

I started seeing this error message today, along with this explanatory text.

"\xC3" from ASCII-8BIT to UTF-8

Any idea what I can do to fix it?

btw, I am using clousre compiler. When I switch to YUI I get this error message instead.

YUI::Compressor::RuntimeError

mickey commented 13 years ago

I get the same error and took the alexandrebini fork in the meantime

yinhm commented 13 years ago

In 1.9, read an non-ASCII file as binary, the content encoding will not be valid.

We can not assume the file was utf-8 neither due to other possibility.

Just read file as normal may be a good choice(also solve this issue), but I don't known is this gonna broken other functions.


diff --git a/lib/jammit/compressor.rb b/lib/jammit/compressor.rb
index 7d62431..d4d1b5d 100644
--- a/lib/jammit/compressor.rb
+++ b/lib/jammit/compressor.rb
@@ -244,7 +244,7 @@ module Jammit

     # `File.read`, but in "binary" mode.
     def read_binary_file(path)
-      File.open(path, 'rb') {|f| f.read }
+      File.open(path, 'r') {|f| f.read }
     end
   end
volkanunsal commented 13 years ago

I tried that, but didn't work for me.

yinhm commented 13 years ago

What was the error raised then?

It maybe raised due to your file was neither ASCII nor utf-8.

volkanunsal commented 13 years ago

Same error(s). But no mention of any files in sight. I'd gladly change the formatting if I knew the file causing this.

jashkenas commented 13 years ago

Is there a particular patch here we can adopt to fix this?