Hello,
I need to edit my function so that it can
work also when special characters are submitted
on unicode format.
Any idea on how I should do that?
The changes I've done below don't work at all
Code:
function hd_dir_safe($string) {
$string = strtr($string,
"!#$%&'()*+,_./:;<=>?@[\]^`{|}~",
" "
);
if ($_SESSION["site_all"]["charmode"] == "UTF-8") {
// this doesn't work when the site content is in UTF-8 format
$string = strtr($string,
utf8_encode("ÀÁÂÃÄÅàáâãäåÈÉÊËèéêëÌÍÎÏìíîïÒÓÔÕÖòóôõöÙÚÛÜùúûüÑñ"),
"aaaaaaaaaaaaeeeeeeeeiiiiiiiioooooooooouuuuuuuunn"
);
} else {
This works when the site content is in ISO format
$string = strtr($string,
"ÀÁÂÃÄÅàáâãäåÈÉÊËèéêëÌÍÎÏìíîïÒÓÔÕÖòóôõöÙÚÛÜùúûüÑñ",
"aaaaaaaaaaaaeeeeeeeeiiiiiiiioooooooooouuuuuuuunn"
);
}
//$string = strtolower($string);
$string = str_replace(" ", "", $string);
$string = str_replace("\"", "", $string);
$string = trim($string);
return $string;
}
Note : the PHP code is in ANSI format (not UTF-8) and
I would like to keep it this way.
Many thanks!