Does anyone have written multibyte variant of function strtr() ? I need this one.
Edit 1 (example of desired usage):
Example:
$from = \'ľ
function mb_strtr($str,$map,$enc){
$out="";
$strLn=mb_strlen($str,$enc);
$maxKeyLn=1;
foreach($map as $key=>$val){
$keyLn=mb_strlen($key,$enc);
if($keyLn>$maxKeyLn){
$maxKeyLn=$keyLn;
}
}
for($offset=0; $offset<$strLn; ){
for($ln=$maxKeyLn; $ln>=1; $ln--){
$cmp=mb_substr($str,$offset,$ln,$enc);
if(isset($map[$cmp])){
$out.=$map[$cmp];
$offset+=$ln;
continue 2;
}
}
$out.=mb_substr($str,$offset,1,$enc);
$offset++;
}
return $out;
}