Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

url_escape not working well for umlaut characters #28

Open
HoneyryderChuck opened this issue May 8, 2012 · 1 comment
Open

url_escape not working well for umlaut characters #28

HoneyryderChuck opened this issue May 8, 2012 · 1 comment

Comments

@HoneyryderChuck
Copy link

Greetings,

I'm having an issue with the gem concerning the escaping of the characters before the api call to google or yahoo is made. Let's say, I have the following address: "Hardturmstrasse 253 Zürich". When the parameters are escaped in order to be inserted in the api call (geocoder.rb, line 594), they are apparently wrongly escaped. So, the call in the same line to Geokit::Inflector::url_escape("Hardturmstrasse 253 Zürich") produces the following result: "Hardturmstrasse+253+Z%C3rich". Well, the api call returns no results for such an address. The specific problem here is how the "ü" character is being escaped. Escaping then "Zürich" with the URI.escape function, I get the following encoding for it: "Z%C3%BCrich". I use it in the api call, and... it works. Do you have any idea why the escaping is going wrong in such cases?

Regards,
Tiago

@HoneyryderChuck
Copy link
Author

just as a short note: I patched the url_escape function with the following:


module GeoKit
  module Inflector
     def url_escape(s)
       s.gsub(/([^ a-zA-Z0-9_.-]+)/nu) do
        '%' + $1.unpack('H2' * $1.size * 2).reject(&:blank?).join('%').upcase
       end.tr(' ', '+')
     end
  end
end


I really don't know if this covers all the special character cases. Maybe you can tell me how could that be rewritten in a better way.

Regards,
Tiago

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant