Символ -> &#код;
Релиб
Форумы       Участники    Календарь    Кто он-лайн?
Добро пожаловать, гость ( Вход | Регистрация )
        



Символ -> &#код; Expand / Collapse
Автор
Сообщение
27.03.2007 21:57
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

участник
Last Login: 04.07.2007 23:09
Сообщ.: 174, Visits: 1 474
собственно вопрос в сабже

Всем заранее благодарен,

Toller

Сообщ. #911951
28.03.2007 0:53
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

участник
Last Login: 04.07.2007 23:09
Сообщ.: 174, Visits: 1 474
Разгадка где-то тут:http://ru.php.net/utf8_encode

То, что мне нужно можно сформулировать еще и вот так: перекодировка в utf-8 на php. вот:)

Сообщ. #911954
28.03.2007 9:45
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

участник
Last Login: 04.07.2007 23:09
Сообщ.: 174, Visits: 1 474
<a href="rbc/">&#1056;&#1041;&#1050;</a><br/>

и выглядит это

<a href="rbc/РБК</a><br/>

вот мне нужно именно это...:(

Сообщ. #911958
28.03.2007 11:14
Supreme Being

Supreme Being

модератор
Last Login: 04.05.2008 13:32
Сообщ.: 7 240, Visits: 65 445
Если тебе нужно именно в UTF-8 перевести строку, то лучше использовать функцию mb_convert_encoding() из расширения mbstring. Если нужны все таки коды то попробуй совет из комментария к функции mb_encode_numericentity (для этого тоже нужно расширение mbstring). Третьим вариантом можно попробовать написать обертку вокруг mb_encode_mimeheader, чтобы она сначала кодировала один символ в Quoted-Printable, затем вручную разбирать результат и получать таким образом код символа в utf-8.
Сообщ. #911966
28.03.2007 11:49
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

участник
Last Login: 04.07.2007 23:09
Сообщ.: 174, Visits: 1 474
Спасибо. Понятно что ничего не понятно...:(

А если у меня ХВОСТИНТ от ВАЛУЙХВОСТ - не поддерживает это все? другие пути еще есть? Вот уж не думал что это такая проблема. пока еще ничего нагуглить не смог... Может есть еще какие-нибудь варианты?

Можно проблему еще и так сформулировать: в базе все хранится в cp1251 - а нужно чтобы на телефоне (Опера) отображалось нормально... Что еще можно попробовать сделать?

Сообщ. #911971
28.03.2007 12:50
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

участник
Last Login: 04.07.2007 23:09
Сообщ.: 174, Visits: 1 474
<?

# Unicode class... be sure you use charset=utf-8 in your html header if you use this.
#
# You are free to use this code, change whatever and redistribute, just leave info about me and
# don't forget to drop me a line if you think this code is useful ;)
#
# Romans (2000)
# romans@lv.net

class utf{
var $map; # loaded charset mappings. You can obtain them at ftp://ftp.unicode.org/Public/MAPPINGS/

function loadmap($filename,$alias){
  # Load table with mapping into array for latter use. Pass alias to cp2utf function..
  $f=fopen($filename,'r') or die();
  while(!feof($f)){
   if($s=chop(fgets($f,1023))){
    list($x,$a,$b)=split('0x',$s);
    $a=hexdec(substr($a,0,2));
    $b=hexdec(substr($b,0,4));
    if($a&&$b)$this->map[$alias][$a]=$b;
   }
  }
}

function cp2utf($str,$alias=''){
  # Translate string ($str) to UTF-8 from given charset ($xcp)
  #  if charset is not present, ISO-8859-1 will be used.

  if($alias==''){
   for($x=0;$x<strlen($str);$x++){
    $xstr.=$this->code2utf(ord(substr($str,$x,1)));
   }
   return $xstr;
  }
  for($x=0;$x<strlen($str);$x++){
   $xstr.=$this->code2utf($this->map[$alias][ord(substr($str,$x,1))]);
  }
  return $xstr;
}

function code2utf($num){
  # Translate numeric code of UTF-8 character code to corresponding character sequence. Refer to www.unicode.org for info.

  if($num<128)return chr($num); // ASCII
  if($num<1024)return chr(($num>>6)+192).chr(($num&63)+128);
  if($num<32768)return chr(($num>>12)+240).chr((($num>>6)&63)+128).chr(($num&63)+128);
  if($num<2097152)return chr($num>>18+240).chr((($num>>12)&63)+128).chr(($num>>6)&63+128).chr($num&63+128);
  return '';
}
}
# EOF
?>

только всеравно не работат:(

Сообщ. #911978
29.03.2007 17:04
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

участник
Last Login: 04.07.2007 23:09
Сообщ.: 174, Visits: 1 474
Большое спасибо всем кто принял участие в обсуждении моей простенькой в общем проблемы. Особеннаая блогдаронсть тебе Toller за это (см. ниже) решение:

function win2utf($in_text){
 
 
$output="";
$other[1025]="&#168;";
$other[1105]="&#184;";
$other[1028]="&#170;";
$other[1108]="&#186;";
$other[1030]="I";
$other[1110]="i";
$other[1031]="&#175;";
$other[1111]="&#191;";
 
for ($i=0; $i<strlen($in_text); $i++){
if (ord($in_text{$i})>191){
  $output.="&#".(ord($in_text{$i})+848).";";
} else {
  if (array_search($in_text{$i}, $other)===false){
   $output.=$in_text{$i};
  } else {
   $output.="&#".array_search($in_text{$i}, $other).";";
  }
}
}
return $output;
}

Сообщ. #912021
« пред. тема | след. тема »


Эту тему читают Expand / Collapse
Посетители: 0 (0 гостей, 0 участников, 0 скрыт.участников)
Сейчас нет участников, просматривающих тему.
Модераторы: Alexey, boombastik, bazile, pl

Время GMT +3:00, Сейчас 10:54