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

  • Home
  • SEARCH
  • 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 6930721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:29:05+00:00 2026-05-27T11:29:05+00:00

Is it possible to get rails to decode query parameters to utf8. If i

  • 0

Is it possible to get rails to decode query parameters to utf8.

If i have something like /foo?param=£

And I try to access the parameter in my controller the parameter is encoded as ASCII-8BIT. This causes lots of things to break because a lot of our other strings are encoded UTF-8 and ruby doesn’t like mixing encodings.

params[:param].encoding == Encoding.find("ASCII-8BIT")
  • 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-05-27T11:29:06+00:00Added an answer on May 27, 2026 at 11:29 am

    This solution is taken from the brilliant article at http://jasoncodes.com/posts/ruby19-rails2-encodings

    Thanks a mill to Jason Weathered for this!

    If you are on the Rails 2.3.x series, you need to create a file called config/initializers/utf8_params.rb with following content to fix the problem

    raise "Check if this is still needed on " + Rails.version unless Rails.version == '2.3.10'
    
    class ActionController::Base
    
      def force_utf8_params
        traverse = lambda do |object, block|
          if object.kind_of?(Hash)
            object.each_value { |o| traverse.call(o, block) }
          elsif object.kind_of?(Array)
            object.each { |o| traverse.call(o, block) }
          else
            block.call(object)
          end
          object
        end
        force_encoding = lambda do |o|
          o.force_encoding(Encoding::UTF_8) if o.respond_to?(:force_encoding)
        end
        traverse.call(params, force_encoding)
      end
      before_filter :force_utf8_params
    
    end
    

    Be sure to check out the other tips in the article, especially around magic comments in views. Thanks again Jason.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to get the text of an OleDbCommand with all parameters replaced
I am making a rails(3.0.11) application using youtube_it api. Is it possible to get
Possible Duplicate: Ruby 1.9.2 and Rails 3 cannot open rails console I have already
Possible Duplicate: Rails 3 Custom Route that takes multiple ids as a parameter From
I have a RESTful rails backend where http requests(GET, PUT, POST, etc.) have much
I have a current Rails 3 app and I'd like to run a poll
Ok so i have been starting to get used to rails 3 over the
Is it possible to somehow do the following in rails? Get the color of
Possible Duplicate: Ruby/Ruby on Rails ampersand colon shortcut As a habit I try and
Possible Duplicate: How do I easily parse a URL with parameters in a Rails

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.