Re: Replacing accented characters
| From: | Daniel Brown | Date: | Thu, 04 Mar 2010 18:07:08 +0000 |
| Subject: | Re: Replacing accented characters | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-302539@lists.php.net to get a copy of this message | ||
On Thu, Mar 4, 2010 at 12:57, Skip Evans <skip@bigskypenguin.com> wrote:
> Hey all,
>
> Does anyone have a function that replaces accented characters
> with the non-accent equals?
This one by Sven on 21-APR-2005:
<?php
function transcribe($string) {
$string = strtr($string,
"\xA1\xAA\xBA\xBF\xC0\xC1\xC2\xC3\xC5\xC7
\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1
\xD2\xD3\xD4\xD5\xD8\xD9\xDA\xDB\xDD\xE0
\xE1\xE2\xE3\xE5\xE7\xE8\xE9\xEA\xEB\xEC
\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF8
\xF9\xFA\xFB\xFD\xFF",
"!ao?AAAAAC
EEEEIIIIDN
OOOOOUUUYa
aaaaceeeei
iiidnooooo
uuuyy");
$string = strtr($string, array("\xC4"=>"Ae",
"\xC6"=>"AE",
"\xD6"=>"Oe", "\xDC"=>"Ue",
"\xDE"=>"TH", "\xDF"=>"ss",
"\xE4"=>"ae",
"\xE6"=>"ae", "\xF6"=>"oe",
"\xFC"=>"ue", "\xFE"=>"th"));
return($string);
}
?>
If you search via Google for 'php accented characters function'
you'll see some user notes with code samples. I grabbed the one above
from strtr() on php.net, and there are several others there and other
places --- like on the preg_replace() page, if memory serves.
--
</Daniel P. Brown>
daniel.brown@parasane.net || danbrown@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Looking for hosting or dedicated servers? Ask me how we can fit your budget!