Опубликовано 28 февраля, 200620 г. comment_1942852 function win3utf($s) { $t = ''; for($i=0, $m=strlen($s); $i<$m; $i++) { $c = ord($s[$i]); if ($c<=127) {$t.=chr($c); continue; } if ($c>=192 && $c<=207) {$t.=chr(208).chr($c-48); continue; } if ($c>=208 && $c<=239) {$t.=chr(208).chr($c-48); continue; } if ($c>=240 && $c<=255) {$t.=chr(209).chr($c-112); continue; } if ($c==184) { $t.=chr(209).chr(209); continue; }; if ($c==168) { $t.=chr(208).chr(129); continue; }; } return $t; } Жалоба
Опубликовано 28 февраля, 200620 г. comment_1942878 Ф-ю пользую давно, у меня всё в порядке echo $text = "Тест"; print "<br />"; echo win3utf($text); Выводит Тест Тест Вы, случаем, UTF-8 с Юникодом не путаете? Жалоба
Опубликовано 28 февраля, 200620 г. Автор comment_1943018 function utf2win1251 ($s){ $out = ""; for ($i=0; $i<strlen($s); $i++) { $c1 = substr ($s, $i, 1); $byte1 = ord ($c1); if ($byte1>>5 == 6){ $i++; $c2 = substr ($s, $i, 1); $byte2 = ord ($c2); $byte1 &= 31; // remove the 3 bit two bytes prefix $byte2 &= 63; // remove the 2 bit trailing byte prefix $byte2 |= (($byte1 & 3) << 6); // last 2 bits of c1 become first 2 of c2 $byte1 >>= 2; // c1 shifts 2 to the right $word = ($byte1<<8) + $byte2; if ($word==1025) $out .= chr(168); // ? elseif ($word==1105) $out .= chr(184); // ? elseif ($word>=0x0410 && $word<=0x044F) $out .= chr($word-848); // ?ߠ else{ $a = dechex($byte1); $a = str_pad($a, 2, "0", STR_PAD_LEFT); $b = dechex($byte2); $b = str_pad($b, 2, "0", STR_PAD_LEFT); $out .= "".$a.$b.";"; } } else { $out .= $c1; } } return $out; } Жалоба
Опубликовано 28 февраля, 200620 г. comment_1943308 QUOTE (Аlex_ @ Feb 28 2006, 10:56) Вы, случаем, UTF-8 с Юникодом не путаете? Вообще-то UTF-8 - это одна из форм представления Юникода. https://academ.club/html/emoticons/wink.gif Жалоба
Опубликовано 6 марта, 200620 г. comment_1973762 QUOTE (D-Light @ Feb 28 2006, 13:24) Вообще-то UTF-8 - это одна из форм представления Юникода. https://academ.club/html/emoticons/wink.gif //scared это еще как получилось? Жалоба
Опубликовано 9 марта, 200620 г. comment_1986658 Раставим точки над и? http://www.unicode.org/glossary/#U QUOTE Unicode. The universal character encoding, maintained by the Unicode Consortium (http://www.unicode.org/). This encoding standard provides the basis for processing, storage and interchange of text data in any language in all modern software and information technology protocols. QUOTE Unicode Encoding Form. A character encoding form that assigns each Unicode scalar value to a unique code unit sequence. The Unicode Standard defines three Unicode encoding forms: UTF-8, UTF-16, and UTF-32. Перевод надо? Жалоба