note 74112 modified in ref.iconv by thiago
| From: | thiago@php.net | Date: | Tue, 29 Jul 2008 17:38:40 +0000 |
| Subject: | note 74112 modified in ref.iconv by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-142902@lists.php.net to get a copy of this message | ||
Note that my mysql_iconv will not translate correctly the Hebrew dotting symbols (Niqqud) - they
will be converted into question marks.
Here is a straightforward (and not very efficient) solution:
<?php
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;
}
?>
--was--
Note that my mysql_iconv will not translate correctly the Hebrew dotting symbols (Niqqud) - they
will be converted into question marks.
Here is a straightforward (and not very efficient) solution:
function utf8_to_windows1255($utf8) {
$windows1255 = "";
$chars = preg_split("//",$utf8);
for ($i=1; $i<count($chars)-1; $i+=2) {
$prefix = ord($chars[$i]);
$suffix = ord($chars[$i+1]);
print ("<p>$prefix $suffix");
if ($prefix==215)
$windows1255 .= chr($suffix+80);
elseif ($prefix==214)
$windows1255 .= chr($suffix+16);
else
$windows1255 .= $chars[$i];
}
return $windows1255;
}
http://php.net/manual/en/ref.iconv.php