ruby - Rails Error: "\xE4" followed by "l" on UTF-8 -
when load css or js files on rails 4.2.6 link tags javascript_include_tag , stylesheet_link_tag error:
encoding::invalidbytesequenceerror @ /app "\xe4" followed "l" on utf-8
i never saw error before. , when load these same files html script like:
<script src="/assets/app/functions.js"></script>
then works.
my app/assets/javascripts/application.js is:
//= require jquery //= require jquery_ujs //= require turbolink__s edited //= require__tree . edited
someone had problem before?
thanks!
ok, since not seem understand short explanation in comments, put answer.
puts "\xe4".force_encoding('iso-8859-1').encode('utf-8') #⇒ ä
that said, either 1 (or many) of stylesheets, or 1 (or many) of javascripts stored in iso-8859-1
encoding. ruby tries read in utf-8
default. should find file causes problems, open in editor , save in utf-8
encoding.
you might bulk update smth like
dir['*/**/*.js', '*/**/*.css'].each |f| file.write f, file.read(f).force_encoding('iso-8859-1').encode('utf-8') end
please aware bulk update might cause opposite problem, if of files contained valid utf-8.
Comments
Post a Comment