function u8($win,$h,$t)
{
global $w8;
$w8[chr($h).chr($t)] = $win;
}
$c1 = chr(208);
$c2 = chr(209);
u8("й",208,185); u8("ц",209,134); u8("у",209,131);
u8("к",208,186); u8("е",208,181); u8("н",208,189);
u8("г",208,179); u8("ш",209,136); u8("щ",209,137);
u8("з",208,183); u8("х",209,133); u8("ъ",209,138);
u8("ф",209,132); u8("ы",209,139); u8("в",208,178);
u8("а",208,176); u8("п",208,191); u8("р",209,128);
u8("о",208,190); u8("л",208,187); u8("д",208,180);
u8("ж",208,182); u8("э",209,141); u8("я",209,143);
u8("ч",209,135); u8("с",209,129); u8("м",208,188);
u8("и",208,184); u8("т",209,130); u8("ь",209,140);
u8("б",208,177); u8("ю",209,142); u8("Й",208,153);
u8("Ц",208,166); u8("У",208,163); u8("К",208,154);
u8("Е",208,149); u8("Н",208,157); u8("Г",208,147);
u8("Ш",208,168); u8("Щ",208,169); u8("З",208,151);
u8("Х",208,165); u8("Ъ",208,170); u8("Ф",208,164);
u8("Ы",208,171); u8("В",208,146); u8("А",208,144);
u8("П",208,159); u8("Р",208,160); u8("О",208,158);
u8("Л",208,155); u8("Д",208,148); u8("Ж",208,150);
u8("Э",208,173); u8("Я",208,175); u8("Ч",208,167);
u8("С",208,161); u8("М",208,156); u8("И",208,152);
u8("Т",208,162); u8("Ь",208,172); u8("Б",208,145);
u8("Ю",208,174); u8("ё",209,145); u8("Ё",208,129);
function utf2win ($text)
{
global $c1,$c2,$w8;
$u = false;
$temp = "";
for($i=0,$len=strlen($text); $i<$len; $i++) {
$c = substr($text,$i,1);
if ($u) {
$c = $w8[$lc.$c];
$temp .= isset($c)?$c:"?";
$u = false;
}
else if ($c==$c1 || $c==$c2) {
$u = true;
$lc = $c;
}
else
$temp .= $c;
}
return $temp;
}