note 120163 added to transliterator.transliterate
| From: | Anonymous | Date: | Mon, 14 Nov 2016 22:04:19 +0000 |
| Subject: | note 120163 added to transliterator.transliterate | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-207102@lists.php.net to get a copy of this message | ||
There are some possibly undesirable conversions with ASCII//TRANSLIT//IGNORE or your users may
require some custom stuff.
You might want to run a substitution up front for certain things, such as when you want 3 letter ISO
codes to replace currency symbols. £ transliterates to "lb", for example, which is
incorrect since it's a currency symbol, not a weight symbol (#).
ASCII//TRANSLIT//IGNORE does a great job within the realm of possibility :-)
When it doesn't do something you want it to, you can set up a CSV with one replacement per line
and run a function like:
function stripByMap($inputString, $mapFile)
{
$csv = file($mapFile);
foreach($csv as $line)
{
$arrLine = explode(',', trim($line));
$inputString = str_replace($arrLine[0],$arrLine[1],$inputString);
}
return $inputString;
}
or you can write some regexes. Transliterating using ASCII//TRANSLIT//IGNORE works so well that
your map probably won't be very long...
----
Server IP: 72.52.91.14
Probable Submitter: 2603:3003:2b05:eb00:d074:15f2:c2b9:486a
----
Manual Page -- http://php.net/manual/en/transliterator.transliterate.php
Edit -- https://master.php.net/note/edit/120163
Del: integrated -- https://master.php.net/note/delete/120163/integrated
Del: useless -- https://master.php.net/note/delete/120163/useless
Del: bad code -- https://master.php.net/note/delete/120163/bad+code
Del: spam -- https://master.php.net/note/delete/120163/spam
Del: non-english -- https://master.php.net/note/delete/120163/non-english
Del: in docs -- https://master.php.net/note/delete/120163/in+docs
Del: other reasons-- https://master.php.net/note/delete/120163
Reject -- https://master.php.net/note/reject/120163
Search -- https://master.php.net/manage/user-notes.php