﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Релиб / Веб-программирование / PHP  / Символ -&amp;gt; &amp;#код; / Latest Posts</title><generator>InstantForum.NET v4.1.4</generator><description>Релиб</description><link>http://www.relib.com/forums/</link><webMaster>robot@relib.com</webMaster><lastBuildDate>Sat, 22 Nov 2008 19:29:01 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Символ -&amp;gt; &amp;#код;</title><link>http://www.relib.com/forums/Topic911951-17-1.aspx</link><description>Большое спасибо всем кто принял участие в обсуждении моей простенькой в общем проблемы. Особеннаая блогдаронсть тебе Toller за это (см. ниже) решение:&lt;/P&gt;&lt;P&gt;function win2utf($in_text){ &lt;BR&gt; &lt;BR&gt; &lt;BR&gt;$output=""; &lt;BR&gt;$other[1025]="&amp;amp;#168;"; &lt;BR&gt;$other[1105]="&amp;amp;#184;"; &lt;BR&gt;$other[1028]="&amp;amp;#170;"; &lt;BR&gt;$other[1108]="&amp;amp;#186;"; &lt;BR&gt;$other[1030]="I"; &lt;BR&gt;$other[1110]="i"; &lt;BR&gt;$other[1031]="&amp;amp;#175;"; &lt;BR&gt;$other[1111]="&amp;amp;#191;"; &lt;BR&gt; &lt;BR&gt;for ($i=0; $i&amp;lt;strlen($in_text); $i++){ &lt;BR&gt;if (ord($in_text{$i})&amp;gt;191){ &lt;BR&gt;  $output.="&amp;amp;#".(ord($in_text{$i})+848).";"; &lt;BR&gt;} else { &lt;BR&gt;  if (array_search($in_text{$i}, $other)===false){ &lt;BR&gt;   $output.=$in_text{$i}; &lt;BR&gt;  } else { &lt;BR&gt;   $output.="&amp;amp;#".array_search($in_text{$i}, $other).";"; &lt;BR&gt;  } &lt;BR&gt;} &lt;BR&gt;} &lt;BR&gt;return $output; &lt;BR&gt;}</description><pubDate>Thu, 29 Mar 2007 17:04:10 GMT</pubDate><dc:creator>Toller</dc:creator></item><item><title>RE: Символ -&amp;gt; &amp;#код;</title><link>http://www.relib.com/forums/Topic911951-17-1.aspx</link><description>&amp;lt;?&lt;/P&gt;&lt;P&gt;# Unicode class... be sure you use charset=utf-8 in your html header if you use this. &lt;BR&gt;# &lt;BR&gt;# You are free to use this code, change whatever and redistribute, just leave info about me and &lt;BR&gt;# don't forget to drop me a line if you think this code is useful ;) &lt;BR&gt;# &lt;BR&gt;# Romans (2000) &lt;BR&gt;# &lt;A href="mailto:romans@lv.net"&gt;romans@lv.net&lt;/A&gt; &lt;/P&gt;&lt;P&gt;class utf{ &lt;BR&gt;var $map; # loaded charset mappings. You can obtain them at &lt;A href="ftp://ftp.unicode.org/Public/MAPPINGS/"&gt;ftp://ftp.unicode.org/Public/MAPPINGS/&lt;/A&gt; &lt;/P&gt;&lt;P&gt;function loadmap($filename,$alias){ &lt;BR&gt;  # Load table with mapping into array for latter use. Pass alias to cp2utf function.. &lt;BR&gt;  $f=fopen($filename,'r') or die(); &lt;BR&gt;  while(!feof($f)){ &lt;BR&gt;   if($s=chop(fgets($f,1023))){ &lt;BR&gt;    list($x,$a,$b)=split('0x',$s); &lt;BR&gt;    $a=hexdec(substr($a,0,2)); &lt;BR&gt;    $b=hexdec(substr($b,0,4)); &lt;BR&gt;    if($a&amp;amp;&amp;amp;$b)$this-&amp;gt;map[$alias][$a]=$b; &lt;BR&gt;   } &lt;BR&gt;  } &lt;BR&gt;} &lt;/P&gt;&lt;P&gt;function cp2utf($str,$alias=''){ &lt;BR&gt;  # Translate string ($str) to UTF-8 from given charset ($xcp) &lt;BR&gt;  #  if charset is not present, ISO-8859-1 will be used. &lt;/P&gt;&lt;P&gt;  if($alias==''){ &lt;BR&gt;   for($x=0;$x&amp;lt;strlen($str);$x++){ &lt;BR&gt;    $xstr.=$this-&amp;gt;code2utf(ord(substr($str,$x,1))); &lt;BR&gt;   } &lt;BR&gt;   return $xstr; &lt;BR&gt;  } &lt;BR&gt;  for($x=0;$x&amp;lt;strlen($str);$x++){ &lt;BR&gt;   $xstr.=$this-&amp;gt;code2utf($this-&amp;gt;map[$alias][ord(substr($str,$x,1))]); &lt;BR&gt;  } &lt;BR&gt;  return $xstr; &lt;BR&gt;} &lt;/P&gt;&lt;P&gt;function code2utf($num){ &lt;BR&gt;  # Translate numeric code of UTF-8 character code to corresponding character sequence. Refer to &lt;A href="http://www.unicode.org"&gt;www.unicode.org&lt;/A&gt; for info. &lt;/P&gt;&lt;P&gt;  if($num&amp;lt;128)return chr($num); // ASCII &lt;BR&gt;  if($num&amp;lt;1024)return chr(($num&amp;gt;&amp;gt;6)+192).chr(($num&amp;amp;63)+128); &lt;BR&gt;  if($num&amp;lt;32768)return chr(($num&amp;gt;&amp;gt;12)+240).chr((($num&amp;gt;&amp;gt;6)&amp;amp;63)+128).chr(($num&amp;amp;63)+128); &lt;BR&gt;  if($num&amp;lt;2097152)return chr($num&amp;gt;&amp;gt;18+240).chr((($num&amp;gt;&amp;gt;12)&amp;amp;63)+128).chr(($num&amp;gt;&amp;gt;6)&amp;amp;63+128).chr($num&amp;amp;63+128); &lt;BR&gt;  return ''; &lt;BR&gt;} &lt;BR&gt;} &lt;BR&gt;# EOF &lt;BR&gt;?&amp;gt;&lt;/P&gt;&lt;P&gt;только всеравно не работат:(</description><pubDate>Wed, 28 Mar 2007 12:50:59 GMT</pubDate><dc:creator>Toller</dc:creator></item><item><title>RE: Символ -&amp;gt; &amp;#код;</title><link>http://www.relib.com/forums/Topic911951-17-1.aspx</link><description>Спасибо. Понятно что ничего не понятно...:(&lt;P&gt;А если у меня ХВОСТИНТ от ВАЛУЙХВОСТ - не поддерживает это все? другие пути еще есть? Вот уж не думал что это такая проблема. пока еще ничего нагуглить не смог... Может есть еще какие-нибудь варианты?&lt;/P&gt;&lt;P&gt;Можно проблему еще и так сформулировать: в базе все хранится в cp1251 - а нужно чтобы на телефоне (Опера) отображалось нормально... Что еще можно попробовать сделать?</description><pubDate>Wed, 28 Mar 2007 11:49:28 GMT</pubDate><dc:creator>Toller</dc:creator></item><item><title>RE: Символ -&amp;gt; &amp;#код;</title><link>http://www.relib.com/forums/Topic911951-17-1.aspx</link><description>Если тебе нужно именно в UTF-8 перевести строку, то лучше использовать функцию mb_convert_encoding() из расширения mbstring. Если нужны все таки коды то попробуй совет из комментария к функции &lt;A href="http://ru.php.net/manual/ru/function.mb-encode-numericentity.php"&gt;mb_encode_numericentity&lt;/A&gt; (для этого тоже нужно расширение mbstring). Третьим вариантом можно попробовать написать обертку вокруг &lt;SPAN id=pageTitle&gt;mb_encode_mimeheader, чтобы она сначала кодировала один символ в Quoted-Printable, затем вручную разбирать результат и получать таким образом код символа в utf-8.&lt;/SPAN&gt;</description><pubDate>Wed, 28 Mar 2007 11:14:58 GMT</pubDate><dc:creator>bazile</dc:creator></item><item><title>RE: Символ -&amp;gt; &amp;#код;</title><link>http://www.relib.com/forums/Topic911951-17-1.aspx</link><description>&amp;lt;a href="rbc/"&amp;gt;&amp;amp;#1056;&amp;amp;#1041;&amp;amp;#1050;&amp;lt;/a&amp;gt;&amp;lt;br/&amp;gt;&lt;/P&gt;&lt;P&gt;и выглядит это &lt;/P&gt;&lt;P&gt;&amp;lt;a href="rbc/РБК&amp;lt;/a&amp;gt;&amp;lt;br/&amp;gt;&lt;/P&gt;&lt;P&gt;вот мне нужно именно это...:(</description><pubDate>Wed, 28 Mar 2007 09:45:37 GMT</pubDate><dc:creator>Toller</dc:creator></item><item><title>RE: Символ -&amp;gt; &amp;#код;</title><link>http://www.relib.com/forums/Topic911951-17-1.aspx</link><description>Разгадка где-то тут:&lt;A href="http://ru.php.net/utf8_encode"&gt;http://ru.php.net/utf8_encode&lt;/A&gt;&lt;/P&gt;&lt;P&gt;То, что мне нужно можно сформулировать еще и вот так: перекодировка в utf-8 на php. вот:)</description><pubDate>Wed, 28 Mar 2007 00:53:34 GMT</pubDate><dc:creator>Toller</dc:creator></item><item><title>Символ -&amp;gt; &amp;#код;</title><link>http://www.relib.com/forums/Topic911951-17-1.aspx</link><description>собственно вопрос в сабже&lt;P&gt;Всем заранее благодарен,&lt;/P&gt;&lt;P&gt;Toller</description><pubDate>Tue, 27 Mar 2007 21:57:34 GMT</pubDate><dc:creator>Toller</dc:creator></item></channel></rss>