Re: Converting accented characters or numeric equivalents to non-accented
| From: | -<[ Rene Brehmer ]>- | Date: | Sat, 18 Jan 2003 16:25:45 +0000 |
| Subject: | Re: Converting accented characters or numeric equivalents to non-accented | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-132104@lists.php.net to get a copy of this message | ||
Hi Ian M. Evans,
On Fri, 17 Jan 2003 14:04:15 -0500, you wrote about "[PHP] Converting
accented characters or numeric equivalents to non-accented" something that
looked like this:
>Does anyone have a quick PHP function for converting accented characters to
>their non-accented forms? It would really help a lot with Amazon searches,
>etc.
Not sure about quick, but the only way I've found that works with 100%
guarantee everytime is to take the string and check it character by
character, and if the ascii value is > 128, simply replace it with the
ascii value marker...
something like this (untested):
for ($i = 0; $i < strlen($string_to_parse); $i++) {
$char = substr($string_to_parse, $i, 1);
if (ord($char) > 128) {
$output_string .= "&#".ord($char).";";
}
else {
$output_string .= $char;
}
}
You may need to test for value 127 ... not sure if it starts on 0 or 1
that is...
The above structure is what I use constantly to do this...
HTH
Rene
--
Rene Brehmer
This message was written on 100% recycled spam.
Come see! My brand new site is now online!
http://www.metalbunny.net