Hi Everyone,
I am currently working on a site that will have lots of European and Middle-Eastern town names that include accented and other special characters. I have never had to deal with these characters before and I foolishly assumed that setting everything to utf-8 would take care of it all for me but I have been pulling my hair out over this for a few hours now and I am hoping that someone here can help me out.
I am calling a web service from GeoNames.org with grid coordinates as arguments. The result is returned in JSON format which I then run through the DeserializeJSON function and pull out the value that I am interested in. However, when I then output that value any special characters are replaced with odd characters like the square root symbol.
I have checked the raw JSON string and found that the characters all look in-tact but somewhere along the way it is getting mangled. The characters are also not displayed correctly if I do a cfdump of the response:
Here's an example of a WS request: http://ws.geonames.org/findNearbyPlaceNameJSON?lat=45.421&lng=0.8382〈=en
and here's a trimmed down version of my page:
<cfprocessingdirective pageEncoding="utf-8">
<cfhttp charset="utf-8" url="http://ws.geonames.org/findNearbyPlaceNameJSON?lat=#Left(getLatLon.lat,6)#&lng=#Left(getLatLon.lon,6)#&lang=en" result="response" />
<cfset response = DeSerializeJSON(response.fileContent) />
<cfdump var="#response#">
<cfset townName = response.geonames[1].name />
<cfcontent type="text/html; charset=utf-8">
<cfoutput>#ToString(townName)#</cfoutput>
</cfcontent>
I realise that I have gone a bit OTT with the utf-8's but it has driven me to it :)
Any help would be much appreciated.
Thanks,
Paulo.