note 74395 deleted from ref.iconv by thiago
| From: | thiago@php.net | Date: | Tue, 29 Jul 2008 17:38:49 +0000 |
| Subject: | note 74395 deleted from ref.iconv by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-142903@lists.php.net to get a copy of this message | ||
Note Submitter:
----
Just a little fix for the utf8_to_windows1255 function above. The original function doesn't
convert English characters well:
function utf8_to_windows1255($utf8) {
$windows1255 = "";
$chars = preg_split("//",$utf8);
for ($i=1; $i<count($chars)-1; $i++) {
$prefix = ord($chars[$i]);
$suffix = ord($chars[$i+1]);
//print ("<p>$prefix $suffix");
if ($prefix==215) {
$windows1255 .= chr($suffix+80);
$i++;
}
elseif ($prefix==214) {
$windows1255 .= chr($suffix+16);
$i++;
}
else {
$windows1255 .= $chars[$i];
}
}
return $windows1255;
}