From 0f0dfb0b9f31a4a6b29e3196446ea92dda102c7b Mon Sep 17 00:00:00 2001 From: x2003bruneau Date: Wed, 20 Sep 2006 12:10:22 +0000 Subject: [PATCH] Backport git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@880 839d8a87-29fc-0310-9880-83ba4fa771e5 --- include/geoloc.inc.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/include/geoloc.inc.php b/include/geoloc.inc.php index 4ba4410..ea90510 100644 --- a/include/geoloc.inc.php +++ b/include/geoloc.inc.php @@ -64,6 +64,16 @@ function _geoloc_region_smarty($params){ $GLOBALS['page']->register_function('geoloc_region', '_geoloc_region_smarty'); // }}} +function geoloc_is_utf8($text) +{ + return (iconv('utf-8', 'utf-8', $text) == $text); +} + +function geoloc_utf8_decode($text) +{ + return geoloc_is_utf8($text) ? utf8_decode($text) : $text; +} + // {{{ get_address_infos($txt) /** retrieve the infos on a text address * store on the fly the info of the city concerned @@ -82,7 +92,7 @@ function get_address_infos($txt) { $infos[$key] = $vals[$i]; } else { $val = strtr($vals[$i], array(chr(197).chr(147) => "œ")); - $infos[$key] = (iconv('utf-8', 'utf-8', $val) == $val) ? utf8_decode($val) : $val; + $infos[$key] = geoloc_utf8_decode($val); } } } @@ -340,6 +350,10 @@ function geoloc_getData_subcities($mapid, $SFields, &$cities, $direct=true) { if ($c['pop'] > 0) { $city = $c; + // $city['name'] = geoloc_utf8_decode($city['name']); + if (!geoloc_is_utf8($city['name'])) { + $city['name'] = utf8_encode($city['name']); + } $city['x'] = geoloc_to_x($c['x'], $c['y']); $city['y'] = geoloc_to_y($c['x'], $c['y']); $city['size'] = size_of_city($c['pop']); -- 2.1.4