I want to send a user's entry to google's geocode API. In doing so, I detected a problem. When I send the user input (e.g. "k?ln+Germany") through my script to the api in Firefox it works great. In Internet Explorer however it's not working.
Here's the exempt of my code that's enough to show the problem:
header('Content-type: text/html; charset=UTF-8');
header('Cache-Control: no-cache, must-revalidate');
$loc = urlencode($_GET['loc']);
echo $address = "http://maps.googleapis.com/maps/api/geocode/json?address=$loc&sensor=false";
The output ($address) in Firefox is: http://maps.googleapis.com/maps/api/geocode/json?address=k%C3%B6ln+Germany&sensor=false (works!)
The same in Internet Explorer is: http://maps.googleapis.com/maps/api/geocode/json?address=k%F6ln+Germany&sensor=false (returns "INVALID_REQUEST")
You can see the difference in the encoding of the ?. In Firefox it's %C3%B6, in IE it's k%F6. If I make the user input "k%C3%B6ln+Germany" to begin with, it works like a charm in Internet Explorer also.
How can I with PHP ensure that the conversion of my special characters is the same in Internet Explorer as in Firefox. So ? = %C3%B6 instead of ? = k%F6
Thank you very much!
Paul
See Question&Answers more detail:os