I faced a problem recently using Graticule with Google geocoder api. Whenever I check for locations whose name contains accentuated chars (like “Orléans”), I was rewarded with a nice REXML exception telling me google xml was not correct (some tags ending missing).
After about an hour of fight with Graticule, then Open-URI, then Net::HTTP, then StringIO and finally google I discovered the problem : Google Geocoder API send xml response with iso-8859-1 unless you fake being…say “Mozilla/5.0”. No matter you specify Accept or Accept-Charset headers the only way to have the xml as utf8 is sending “User-Agent: Mozilla/5.0”.
In fact it works with different versions :“Mozilla/5.0”, “Mozilla 5.0”, “Mozilla 5.0 (give me utf8 please)”, etc.
So if you want to use Graticule to geolocalize locations with accentuated chars change in graticule’s “rest.rb” (around line 80) :
url.open do |response|
url.open('User-Agent' => 'Mozilla 5.0 (Some utf8 please)') do |response|