incompatible character encodings: ASCII-8BIT and UTF-8
I have a suspicion that you either copy/pasted a part of your Haml template into the file, or you're working with a non-Unicode/non-UTF-8 friendly editor.
See if you can recreate that file from the scratch in a UTF-8 friendly editor. There are plenty for any platform and see whether this fixes your problem. Start by erasing the line with #content
and retyping it manually.
incompatible character encodings: ASCII-8BIT and UTF-8 in Oga gem
The bit of code you linked has nothing to do with the glitch, that is the issue of body is being interpreted in wrong encoding. Try adding body = body.force_encoding 'UTF-8'
before parsing a document:
def get_page
body = Net::HTTP.get(URI.parse(@url)).force_encoding 'UTF-8'
document = Oga.parse_html(body)
end
incompatible character encodings: ASCII-8BIT and UTF-8 and debug(params)
- Try to recreate your template file from scratch in a UTF-8 friendly editor.
- Put
config.encoding = "utf-8"
in your application.rb file. Add this code in your environment.rb:
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
If you are working with MySql use the "mysql2" gem.
- Put
# encoding: utf-8
at the top of your file.
Related Topics
Difference Between ≪%, ≪%=, ≪%# and -%≫ in Erb in Rails
Getting Output of System() Calls in Ruby
How to Sort an Array in Descending Order in Ruby
Why Use Symbols as Hash Keys in Ruby
How to Modify Path For Homebrew
What Exactly Is the Singleton Class in Ruby
Installing Bootstrap 3 on Rails App
Ruby MySQL2 Gem Installation on Windows 7
How to Have Methods Inside Methods
Why Am I Getting Objects Printed Twice
Understanding the "||" or Operator in If Conditionals in Ruby
Aws S3: the Bucket You Are Attempting to Access Must Be Addressed Using the Specified Endpoint
Finding the Cause of a Memory Leak in Ruby
Error: Failed to Build Gem Native Extension on Mavericks