I’m building a Google Maps implementation for a Swedish company, so the language has lots of uses of ä, å, and ö. I have no problems getting the special characters to display correctly (the site charset is UTF-8) except in the “title” attributes for each map marker. My code for the markers is (you can ignore everything in square brackets):
var marker = new google.maps.Marker({
position: [coordinates],
map: [map container div],
icon: [icon image],
title: "Läs mer om "+[text from JSON] //THIS IS WHERE THE PROBLEM IS
});
When I hover over the marker on the map, the tooltip comes up as “L�s mer om…”. If I change the “ä” to ä in the Javascript, the tooltip displays “Läs mer om...” instead.
The kicker is that using special characters anywhere else in the site, either directly in raw HTML or generated text placed by CMS or what-have-you works just fine. It’s only in the Google Maps implementation that it’s cracking.
Again, given that the site is entirely in Swedish, this could be a fairly significant issue. Any bright ideas from SO resident geniuses?
I had give it a try and it worked here ,
if you need to test it so fast try
console.log("L\u00e4s mer om")oralert("L\u00e4s mer om")it would output“Läs mer om “
Source : http://www.ietf.org/rfc/rfc4627.txt
explanation :
since the marker is an JS object , so it should follow the upper listed rules
okay then what to do ???
use
<?php echo json_encode("Läs mer om "); ?>or what ever your serverside language isand append the value to your JSON object or write it manually and Go on !!