Pph Конвертер win1251 в utf8

Функция преобразования кодировки текста из win-1251 в utf-8. Во входной параметр подаем текс который необходимо конвертировать

<?php 
function convert($text)
{
$tmp="";
for($i=0, $m=strlen($text); $i< $m; $i++)
{
$char=ord($text[$i]);

if ($char<=127) {$tmp.=chr($char); continue; }
if ($char>=192 && $char< =207)    {$tmp.=chr(208).chr($char-48); continue; }
if ($char>=208 && $char< =239) {$tmp.=chr(208).chr($char-48); continue; }
if ($char>=240 && $char< =255) {$tmp.=chr(209).chr($char-112); continue; }
if ($char==184) { $tmp.=chr(209).chr(145); continue; };
if ($char==168) { $tmp.=chr(208).chr(129);  continue; };
}
return $tmp;
}
?>

Leave a Reply

Ваш адрес email не будет опубликован. Обязательные поля помечены *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>