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 7071149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:39:11+00:00 2026-05-28T05:39:11+00:00

I’m using Rails 3.0.3 with REE ( Ruby 1.8.7 ) and gem ‘mysql2’, ‘0.2.6’

  • 0

I’m using Rails 3.0.3 with REE ( Ruby 1.8.7 ) and gem ‘mysql2’, ‘0.2.6’

There’s a search feature in my project that enable people to use the GET method using URL or using forms and then generate the URL.

Example:

I want to search:

origin city: “Århus, Denmark” and destination city: “Asunción, Paraguay“

they both have a special character: “Å” and “ó“, so the URL will be generated like this when someone click the search button.

?&origin=%C5rhus%2C%20Denmark&destination=Asunci%F3n%2C%20Paraguay

Problem:

When i search that city, it’s not unescaped like i want ( i tried using like CGI, URI, even some gems).

When i see at the console, ActiveRecord received the query like this:

Parameters: {"destination"=>"Asunci�n, Paraguay", "origin"=>"�rhus, Denmark", "sort"=>"newest"}
City Load (0.1ms)  SELECT `cities`.* FROM `cities` WHERE (`cities`.`name` = '�rhus') ORDER BY cities.name ASC
City Load (6.8ms)  SELECT `cities`.* FROM `cities` WHERE (`cities`.`name` = 'Asunci�n, Paraguay') ORDER BY cities.name ASC

Conclusion: the cities can’t be found 🙁

But, i found an interesting thing:

  • When i made an error on the file asociated with this function, the output will be like this :

    Request

    Parameters:
    {"destination"=>"Asunción,
    Paraguay",
    "origin"=>"Århus,
    Denmark",
    "sort"=>"newest"}
    

it’s a valid one!

Question:

Do you guys have an idea how to solve this? Thanks in advance 🙂

  • 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-28T05:39:11+00:00Added an answer on May 28, 2026 at 5:39 am

    You’re right, it looks like you have an encoding problem somewhere. The 0xC5 character is “Å” in ISO-8859-1 (AKA Latin-1), in UTF-8 it would be %C3%85 in the URL.

    I suspect that you’re using JavaScript on the client side and that your JavaScript is using the old escape function to build the URL, escape has some issues with non-ASCII characters. If this is the case, then you should upgrade your JavaScript to use encodeURIComponent instead. Have a look at this little demo and you’ll see what I’m talking about:

    http://jsfiddle.net/ambiguous/U5A3k/

    If you can’t change the client-side script then you can do it the hard way in Ruby using force_encoding and encoding:

    >> s = CGI.unescape('%C5rhus%2C%20Denmark')
    => "\xC5rhus, Denmark"
    >> s.encoding
    => #<Encoding:UTF-8>
    >> s.force_encoding('iso-8859-1')
    => "\xC5rhus, Denmark"
    >> s.encoding
    => #<Encoding:ISO-8859-1>
    >> s.encode!('utf-8')
    => "Århus, Denmark"
    >> s.encoding
    => #<Encoding:UTF-8>
    

    You should get something like "\xC5rhus, Denmark" from params and you could unmangle that with:

    s = params[:whatever].force_encoding('iso-8859-1').encode('utf-8')
    

    Dealing with this on the server side would be a last resort though, if your client-side code is sending back incorrectly encoded data then you’ll be left with a pile of guesswork on the server to figure out what encoding was actually used to get it into the URL.

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have a French site that I want to parse, but am running into

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.