I'm kinda new to javascript running on Apache but I have the following problem.
I use escape to make the string "Café" ready for usage in an url using javascript.
"&place=" + escape(placename);
The String is translated to "Caf%E9" and then represented as "Café" in the next page, which is a php page.
All is fine, however, when I upload the code to my webhost it is translated to "Caf%C3%A9". And shown in the page as "Café".
I use UTF-8 for the decoding. My webhost uses iconv.input_encoding ISO-8859-1.
I think here lies the problem. What would be the best way to fix this? Change my UTF-8 to ISO-8859-1 or is there some converter function ?
EDIT I have the UTF8 meta tags
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
I also tried to use encodeURIComponent but it gives the same result
"&place=" + encodeURIComponent(placename);
EDIT: added code
This is the code, it behaves differently locally than on the web. The code uses the Google Maps API.
var lat = place.geometry.location.lat();
var lng = place.geometry.location.lng();
var placename = place.name;
var placerating = place.rating;
if (placerating == undefined) {
placerating = 0;
}
var placeaddress = place.vicinity;
var website = place.website;
var url = place.url;
var day = new Date();
var m = day.getMonth() + 1;
var d = day.getDate();
var y = day.getFullYear();
var formUrl = "myform.php?d=" + d + "&m=" + m + "&y=" + y + "&lat=" + lat + "&lng=" + lng + "&place=" + encodeURIComponent(placename);
Note, when I alert(placename) it gives me the same result on both environments. namely, "Café"
SOLUTION
My webhost used another encoding which forces the page to use ISO-8859-1. Even though I used the html meta tags.
add the following PHP header to the beginning of the pages
header("Content-type: text/html; charset=utf-8");
TIA, Coen