note 110599 deleted from normalizer.normalize by aharvey
| From: | aharvey@php.net | Date: | Mon, 12 Nov 2012 01:37:40 +0000 |
| Subject: | note 110599 deleted from normalizer.normalize by aharvey | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-191884@lists.php.net to get a copy of this message | ||
Note Submitter: Felix Riesterer
----
I don't have the normalizer class supported on my shared hosting so I used my word processor to
get all those funny characters with "diacritics" and put them into this simple function in
order to get a normalized lowercase output:
<?php
function normalize_utf8_tolower ($s) {
// replacements for lower-case ASCII-characters
$r = array(
'a' =>
'AaÃÃÃÃÃ
à áâãåÄÄÄÄÄÄ
ÇÇǺǻ'
.
'ẠạẢảẤấẦầẨẩẪẫẬáºáº®áº¯áº°áº±áº²áº³áº´áºµáº¶áº·Î',
'ae' => 'ÃäæÃǼǽ',
'b' => 'bB',
'c' => 'CcÃçÄÄÄÄÄÄÄÄ',
'd' => 'DdÃÄÄÄÄ',
'e' =>
'EeÃÃÃÃèéêëÄÄÄÄÄÄÄÄÄÄẸẹẺẻẼẽẾếá»á»á»á»á»á»
á»á»Î',
'f' => 'FfÆ',
'g' => 'GgÄÄÄÄÄ Ä¡Ä¢Ä£',
'h' => 'HhĤĥĦħÎ',
'i' =>
'IiÃÃÃÃìÃîïĨĩĪīĬÄĮįİıÇÇá»á»á»á»ÎÎ',
'ij' => 'IJij',
'j' => 'JjĴĵ',
'k' => 'KkĶķĸ',
'l' => 'LlĹĺĻļĽľĿÅÅÅ',
'm' => 'Mm',
'n' => 'NnÃñÅÅÅ
ÅÅÅÅ',
'ng' => 'ÅÅ',
'o' =>
'OoÃÃÃÃÃòóôõøÅÅÅÅÅÅÆ Æ¡ÇÇǾǿÎ'
.
'á»á»á»á»á»á»á»á»á»á»á»á»á»á»á»á»á»á»á»á»á» ỡỢợ',
'oe' => 'ÃöÅÅ',
'p' => 'Pp',
'q' => 'Qq',
'r' => 'RrÅÅÅÅÅÅ',
's' => 'SsÅÅÅÅÅÅÅ Å¡',
'ss' => 'ÃÃ',
't' => 'TtŢţŤťŦŧ',
'u' =>
'UuÃÃÃŨũŪūŬÅŮůŰűŲųƯưÇÇ'
.
'ÇÇÇÇÇÇÇÇùúûỤụỦủỨứỪừỬá»á»®á»¯á»°á»±',
'ue' => 'Ãü',
'v' => 'Vv',
'w' => 'WwŴŵáºáºáºáºáºáº
',
'x' => 'Xx',
'y' =>
'YyÃýÿŶŷŸÎỲỳỴỵỶỷỸỹ',
'z' => 'ZzŹźŻżŽž'
);
// replace
foreach ($r as $c => $variants) {
$s = preg_replace("~[$variants]~su", $c, $s);
}
return $s;
}
?>
Note: I might be oh so wrong about certain replacements (like 'ÅÅ'=>
'ng') but for me the above worked just fine.