admin管理员组文章数量:1401425
I'm trying to create a gem that wraps d3.js, Source can be found at
So when I include this gem in my Gemfile
gem "d3-rails", :git => "git://github/iblue/d3-rails.git"
And when I include the javascript in my application.js:
//=require d3
Then my asset pilation fails and my piled application.js just contains
throw Error("Encoding::CompatibilityError: inpatible character encodings: UTF-8 and ASCII-8BIT")
I am using Rails 3.1.3 and ruby-1.9.3-p125. jQuery uses exactly the same gem structure and it works. What am I doing wrong?
EDIT:
I also saw this question: Ruby 1.9 throwing javascript encoding error. This does not apply here, my file is valid UTF-8:
ruby-1.9.3-p125 :001 > d = File.read("./d3.js")
=> [...]
ruby-1.9.3-p125 :002 > d.encoding
=> #<Encoding:UTF-8>
ruby-1.9.3-p125 :003 > d.valid_encoding?
=> true
EDIT 2:
I also tried to insert some voodoo in my config/environment.rb
. It does not work:
# -*- encoding : utf-8 -*-
# Load the rails application
require File.expand_path('../application', __FILE__)
# --------- VOODOO BEGINS HERE -----------------
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
# --------- END VOODO --------------------------
# Initialize the rails application
Ratecode::Application.initialize!
I'm trying to create a gem that wraps d3.js, Source can be found at https://github./iblue/d3-rails
So when I include this gem in my Gemfile
gem "d3-rails", :git => "git://github./iblue/d3-rails.git"
And when I include the javascript in my application.js:
//=require d3
Then my asset pilation fails and my piled application.js just contains
throw Error("Encoding::CompatibilityError: inpatible character encodings: UTF-8 and ASCII-8BIT")
I am using Rails 3.1.3 and ruby-1.9.3-p125. jQuery uses exactly the same gem structure and it works. What am I doing wrong?
EDIT:
I also saw this question: Ruby 1.9 throwing javascript encoding error. This does not apply here, my file is valid UTF-8:
ruby-1.9.3-p125 :001 > d = File.read("./d3.js")
=> [...]
ruby-1.9.3-p125 :002 > d.encoding
=> #<Encoding:UTF-8>
ruby-1.9.3-p125 :003 > d.valid_encoding?
=> true
EDIT 2:
I also tried to insert some voodoo in my config/environment.rb
. It does not work:
# -*- encoding : utf-8 -*-
# Load the rails application
require File.expand_path('../application', __FILE__)
# --------- VOODOO BEGINS HERE -----------------
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
# --------- END VOODO --------------------------
# Initialize the rails application
Ratecode::Application.initialize!
Share
Improve this question
edited May 23, 2017 at 11:53
CommunityBot
11 silver badge
asked Mar 1, 2012 at 22:42
iblueiblue
30.4k20 gold badges92 silver badges129 bronze badges
2
- Ever tried to check presence of en.wikipedia/wiki/Byte_order_mark ? Also try bisection: remove parts of the file to see, whether things would start working. – kirilloid Commented Mar 6, 2012 at 14:28
- Can you also check the encoding of the application.js? The error says the two files are inpatible, you should check not only that the d3 file is UTF-8, but also that your application.js is. – mixonic Commented Mar 6, 2012 at 15:01
1 Answer
Reset to default 9Is the error from a WEBrick server or something else? Does rake assets:prepile
work? (don't forget to clear the assets after)
If the latter fails, double check the value of your $LANG environment variables is UTF-8 (with env
). If the rake task works but the app is failing then it could be the server env vars.
本文标签: javascriptAsset pipeline encoding problems (UTF8 vs ASCII8BIT) with external gemStack Overflow
版权声明:本文标题:javascript - Asset pipeline encoding problems (UTF-8 vs. ASCII-8BIT) with external gem - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744309256a2599950.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论