Incompatible Character Encodings: Ascii-8Bit and Utf-8

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)

  1. Try to recreate your template file from scratch in a UTF-8 friendly editor.
  2. Put config.encoding = "utf-8" in your application.rb file.
  3. Add this code in your environment.rb:

    Encoding.default_external = Encoding::UTF_8

    Encoding.default_internal = Encoding::UTF_8

  4. If you are working with MySql use the "mysql2" gem.

  5. Put # encoding: utf-8 at the top of your file.


Related Topics



Leave a reply



Submit