Sprockets encoding error on js file: invalid UTF-8 byte sequence

て烟熏妆下的殇ゞ 提交于 2019-11-29 12:27:25

问题


A Sprockets::EncodingError exception is thrown when I include a file with characters that are valid utf-8.

The line in question is:

* Copyright (c) 2010 - 2011 Johan Säll Larsson

If I replace the ä character, the problem goes away, but I don't want to have to remember to edit this vendor file everytime I update it.

How can I fix this?


回答1:


I found the solution via the comments on this Sprockets issue:

I simply saved the file as utf-8, (TextMate has an option to do this when you chose 'Save As'), and the problem went away.

The commenter @shedd also created a useful rake task to find assets which are not encoded properly.




回答2:


This is fixed in trunk. All files use utf-8 without BOM.



来源:https://stackoverflow.com/questions/7837350/sprockets-encoding-error-on-js-file-invalid-utf-8-byte-sequence

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!