<% // utility to convert XML entities to HTML entities function encode($string) { $entities = array(' & ' => ' & ', '&' => ' & ', '<' => '<', '>' => '>', ''' => "'", '"' => '"'); $string = strtr(utf8_decode($string), $entities); return htmlentities($string, ENT_QUOTES); } // utility to convert XML entities to regular characters function xml_decode($string, $space = true) { if ($space) $entities = array(' & ' => ' & ', '&' => ' & ', '<' => '<', '>' => '>', ''' => "'", '"' => '"'); else $entities = array('&' => '&', '&' => '&', '<' => '<', '>' => '>', ''' => "'", '"' => '"'); return strtr(utf8_decode($string), $entities); } // utility to remove accents from characters function accents($string) { $accents = array('à' => 'a', 'á' => 'a', 'â' => 'a', 'ã' => 'a', 'ä' => 'a', 'å' => 'a', 'ç' => 'c', 'è' => 'e', 'é' => 'e', 'ê' => 'e', 'ë' => 'e', 'ì' => 'i', 'í' => 'i', 'î' => 'i', 'ï' => 'i', 'ò' => 'o', 'ó' => 'o', 'ô' => 'o', 'õ' => 'o', 'ö' => 'o', 'ù' => 'u', 'ú' => 'u', 'û' => 'u', 'ü' => 'u'); $string = str_replace(''', "'", $string); $string = htmlentities($string, ENT_NOQUOTES, 'UTF-8'); return strtr($string, $accents); } %>