Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8382195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:52:32+00:00 2026-06-09T16:52:32+00:00

Hope someone will help me :) So i was having problems with utf8 encoding,

  • 0

Hope someone will help me 🙂

So i was having problems with utf8 encoding, when using utf8 chars in my views, for example, from db..

I got this error:

incompatible character encodings: ASCII-8BIT and UTF-8

And btw, it wasnt a problem wih coding from db..
Anyway, I found the solution for my problem, and it was, to change method in

Ruby193\lib\ruby\gems\1.9.1\gems\activesupport-3.2.6\lib\active_support\core_ext\string\output_safety.rb

The method i changed was “concat”. So i changed this method:

def concat(value)
  if !html_safe? || value.html_safe?
    super(value)
  else
    super(ERB::Util.h(value))
  end
end
alias << concat

to this:

def concat(value)
  value = (value).force_encoding('UTF-8')
  if !html_safe? || value.html_safe?
    super(value)
  else
    super(ERB::Util.h(value))
  end
end
alias << concat

But ofcourse its a bad idea, since, the app wont work on other servers..

So i want to override this method from my initializers, so i created:

config/initializers/utf8_fix.rb

with this code:

module ActiveSupport #:nodoc:
  class SafeBuffer < String
    def self.concat(value)
      value = (value).force_encoding('UTF-8')
      puts "--------------------------------"
      puts "Loaded concat in utf8fix.rb"
      puts "--------------------------------"
      if !html_safe? || value.html_safe?
        super(value)
      else
        super(ERB::Util.h(value))
      end
    end
    alias << concat
  end
end

But it seems that it dosnt override the default method. So can someone tell me, what am i doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T16:52:33+00:00Added an answer on June 9, 2026 at 4:52 pm

    As “concat” is not class method i dosnt need self before it, so that was my problem..

    Solved changing:

    def self.concat(value)
    

    to:

    def concat(value)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hope someone can help me out with this problem I am having. I just
I hope someone can help me here. I'm having trouble loading this variable. Right
The last minimized code is, I hope it will help someone: $(#menu).find(a).hover(function(){ $(this).addClass(active); },function(){
I really hope someone will be able to help me out with this. I
Hope someone will give me a hand with this problem I have. So here
I tried everything to get this code working, and I hope someone will save
Hope someone could help me with this: I would like to have a column
Hope someone can help i cant seem to get my head around this, i
I'm having some javascript conflict problem, and hope someone can help me out. I'm
I have a very simple question, so I hope someone will help. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.