note 115248 added to function.recode-string
| From: | mori at homoeopathy dot co dot jp | Date: | Fri, 20 Jun 2014 06:54:04 +0000 |
| Subject: | note 115248 added to function.recode-string | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-199723@lists.php.net to get a copy of this message | ||
function Romaji2Kana works pretty good but few exception: "JA" and "DZA" were
not converted correctly as Japanese speekes expected. Following is a correction of that behavior.
public function convert($s, $mode='hiragana')
{
$s = strtoupper(str_replace(
- Array('shi', 'sh', 'fu', 'chi',
'ch', 'tsu', 'dz', 'l', '-',
+ Array('shi', 'sh', 'fu', 'chi',
'ch', 'tsu', 'dzi', 'ji', 'j', 'l',
'-',
'â', 'î', 'û',
'ê', 'ô', 'Ä', 'Ä«', 'Å«',
'Ä', 'Å'),
- Array('si', 'sy', 'hu', 'ti',
'ty', 'tu', 'j', 'r', '^',
+ Array('si', 'sy', 'hu', 'ti',
'ty', 'tu', 'zi', 'zi', 'dz','r',
'^',
'a^', 'i^', 'u^', 'e^',
'o^', 'a^', 'i^', 'u^', 'e^', 'o^'),
$s));
+ // DZA -> ZIya
+ $s = preg_replace('/DZ([AUO])/e',
'"ZI".strtolower("y\1")', $s);
+ // DZE -> ZIe
+ $s = preg_replace('/DZ([E])/e',
'"ZI".strtolower("\1")', $s);
// FO -> FUxo
$s = preg_replace('@F([AIOE])@e',
'"HU".strtolower("\1")', $s);
// VO -> VUxo
----
Server IP: 72.52.91.14
Probable Submitter: 210.166.188.202
----
Manual Page -- http://php.net/manual/en/function.recode-string.php
Edit -- https://master.php.net/note/edit/115248
Del: integrated -- https://master.php.net/note/delete/115248/integrated
Del: useless -- https://master.php.net/note/delete/115248/useless
Del: bad code -- https://master.php.net/note/delete/115248/bad+code
Del: spam -- https://master.php.net/note/delete/115248/spam
Del: non-english -- https://master.php.net/note/delete/115248/non-english
Del: in docs -- https://master.php.net/note/delete/115248/in+docs
Del: other reasons-- https://master.php.net/note/delete/115248
Reject -- https://master.php.net/note/reject/115248
Search -- https://master.php.net/manage/user-notes.php