note 48901 added to function.convert-cyr-string

From: Date: Tue, 11 Jan 2005 14:36:39 +0000
Subject: note 48901 added to function.convert-cyr-string
Groups: php.notes 
Request: Send a blank email to php-notes+get-83082@lists.php.net to get a copy of this message
Here's a WORKING function to convert from UTF-8 to Windows-1251, if your hosting provider does not support iconv <?php 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.convert-cyr-string.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+48901 Delete -- http://master.php.net/manage/user-notes.php?action=delete+48901&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+48901&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+48901&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+48901&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+48901&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+48901&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+48901&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#83082) next »