note 110599 added to normalizer.normalize
| From: | FelixRiesterer | Date: | Sun, 11 Nov 2012 15:45:16 +0000 |
| Subject: | note 110599 added to normalizer.normalize | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-191867@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 69.147.83.199
Probable Submitter: 91.18.130.131
----
Manual Page -- http://www.php.net/manual/en/normalizer.normalize.php
Edit -- https://master.php.net/note/edit/110599
Del: integrated -- https://master.php.net/note/delete/110599/integrated
Del: useless -- https://master.php.net/note/delete/110599/useless
Del: bad code -- https://master.php.net/note/delete/110599/bad+code
Del: spam -- https://master.php.net/note/delete/110599/spam
Del: non-english -- https://master.php.net/note/delete/110599/non-english
Del: in docs -- https://master.php.net/note/delete/110599/in+docs
Del: other reasons-- https://master.php.net/note/delete/110599
Reject -- https://master.php.net/note/reject/110599
Search -- https://master.php.net/manage/user-notes.php