Перейти к содержанию
Посмотреть в приложении

A better way to browse. Learn more.

Форум Академгородка, Новосибирск

A full-screen app on your home screen with push notifications, badges and more.

Чтобы установить это приложение на iOS и iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
Чтобы установить это приложение на Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

php utf-8 -> win-1251

Рекомендуемые сообщения

Опубликовано
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;
}

Опубликовано

Ф-ю пользую давно, у меня всё в порядке

echo $text = "Тест";
print "<br />";
echo win3utf($text);

Выводит

Тест
Тест

 

Вы, случаем, UTF-8 с Юникодом не путаете?

Опубликовано
  • Автор
	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;
}

Опубликовано

QUOTE (Аlex_ @ Feb 28 2006, 10:56)
Вы, случаем, UTF-8 с Юникодом не путаете?

Вообще-то UTF-8 - это одна из форм представления Юникода. https://academ.club/html/emoticons/wink.gif

Опубликовано

QUOTE (D-Light @ Feb 28 2006, 13:24)
Вообще-то UTF-8 - это одна из форм представления Юникода. https://academ.club/html/emoticons/wink.gif

//scared

 

это еще как получилось?

Опубликовано

Раставим точки над и?

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.

Перевод надо?

Присоединяйтесь к обсуждению

Вы можете написать сейчас и зарегистрироваться позже. Если у вас есть аккаунт, авторизуйтесь, чтобы опубликовать от имени своего аккаунта.

Гость
Ответить в этой теме...

Аккаунт

Навигация

Поиск

Поиск

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.