note 35443 added to function.utf8-decode
| From: | (bn2@ukr.net) | Date: | Mon, 01 Sep 2003 13:56:09 +0000 |
| Subject: | note 35443 added to function.utf8-decode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-55404@lists.php.net to get a copy of this message | ||
Function to decode uft8 to win-1251 (russian) charset. Don't support ukrainian letters. Support
only 2-byte coding.
function utf8win1251($s){
$out="";$c1="";$byte2=false;
for ($c=0;$c<strlen($s);$c++){
$i=ord($s[$c]);
if ($i<=127) $out.=$s[$c];
if ($byte2){
$new_c2=($c1&3)*64+($i&63);
$new_c1=($c1>>2)&5;
$new_i=$new_c1*256+$new_c2;
if ($new_i==1025) $out_i=168; else
if ($new_i==1105) $out_i=184; else $out_i=$new_i-848;
$out.=chr($out_i);
$byte2=false;}
if (($i>>5)==6) {$c1=$i;$byte2=true;}
}
return $out;}
----
Manual Page -- http://www.php.net/manual/en/function.utf8-decode.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35443
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35443&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35443&report=yes