Skip Menu |

This queue is for tickets about the Geo-Coder-GoogleMaps CPAN distribution.

Report information
The Basics
Id: 49483
Status: resolved
Priority: 0/
Queue: Geo-Coder-GoogleMaps

People
Owner: Nobody in particular
Requestors: SREZIC [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.2
Fixed in: (no value)



Subject: Encoding problems with non-latin1 data and json transport
With the following script: #!/usr/bin/perl use strict; use Geo::Coder::GoogleMaps; my $apikey = ...; my $gmap = Geo::Coder::GoogleMaps->new(apikey => $apikey); my $location = $gmap->geocode(location => 'Djakovo, Croatia'); print $location->{data}{address}, "\n"; __END__ I get the result "\u0110akovo, Croatia". It seems that the first character (D with a stroke) was not decoded properly. I don't know if JSON::Syck does support javascript escapes at all, or if you better switch to JSON::XS instead? Also, if I try to use "Basks Voda, Croatia" as input, then the output is (using Data::Dumper notation): "Ba\x{9a}ka Voda, Croatia". This also does not right, as \x9a is not a valid (Unicode) character. It looks rather like a Windows-1252 fallback (for the letter "S with caron"). This is probably the fault of Google, but it would be nice if this could also be workarounded. Regards, Slaven
On Mon Sep 07 03:38:51 2009, SREZIC wrote: Show quoted text
> With the following script: > > #!/usr/bin/perl > > use strict; > use Geo::Coder::GoogleMaps; > > my $apikey = ...; > my $gmap = Geo::Coder::GoogleMaps->new(apikey => $apikey); > my $location = $gmap->geocode(location => 'Djakovo, Croatia'); > print $location->{data}{address}, "\n"; > > __END__ > > I get the result "\u0110akovo, Croatia". It seems that the first > character (D with a stroke) was not decoded properly. I don't know if > JSON::Syck does support javascript escapes at all, or if you better > switch to JSON::XS instead? > > Also, if I try to use "Basks Voda, Croatia" as input, then the output is > (using Data::Dumper notation): "Ba\x{9a}ka Voda, Croatia". This also > does not right, as \x9a is not a valid (Unicode) character. It looks > rather like a Windows-1252 fallback (for the letter "S with caron"). > This is probably the fault of Google, but it would be nice if this could > also be workarounded.
I just stumbled over this ticket: https://rt.cpan.org/Ticket/Display.html?id=35173 describing a similar problem in Geo::Coder::Google, and the proposed solution there (setting a custom User-Agent string) also works here. So my current workaround is: my $gmap = Geo::Coder::GoogleMaps->new(apikey => $apikey, ua => LWP::UserAgent->new(agent =>"Mozilla/5.0 (compatible; Geo::Coder::GoogleMaps/$Geo::Coder::GoogleMaps::VERSION; Google, please stop smoking crack; http://rt.cpan.org/Public/Bug/Display.html?id=35173)") ); Regards, Slaven Regards, Slaven
On Mon Sep 07 06:38:51 2009, SREZIC wrote: [...] Show quoted text
> Also, if I try to use "Basks Voda, Croatia" as input, then the output is
Typo, this should be "Baska Voda, Croatia". Regards, Slaven
By the time I got through this ticket you give both the bug report and the solution :-) Thank you I am adding a default custom user agent right now. Regards, Arnaud Dupuis
I fixed the issue using the trick you provided, and now the result seems just fine : <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <kml xmlns="http://earth.google.com/kml/2.1"> <Placemark id="p1"> <AddressDetails xmlns="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0"> <Country> <CountryName>Hrvatska</CountryName> <AdministrativeArea> <AdministrativeAreaName>Osječko-baranjska</AdministrativeAreaName> <Locality/> </AdministrativeArea> <CountryNameCode>HR</CountryNameCode> </Country> </AddressDetails> <address>Đakovo, Croatia</address> <ExtendedData> <LatLonBox north="45.3707943" south="45.2452366" east="18.5360083" west="18.2798895"/> </ExtendedData> <Point> <coordinates>18.4079489,45.3080502,0</coordinates> </Point> </Placemark> </kml> The fix is not yet available on CPAN but it's available on the SVN at : https://code.google.com/p/geo-coder-googlemaps/source/browse/ This code is not yet ready for release but its fixing the issue already.
done in version 0.3.
done in version 0.3.