±M·~¹Î¶¤´£¨Ñ§ìº|¡B¨¾¤ô¡B±Mªv©_©Çº|¤ô §K¶O¨ì©²¦ô»ù¡Aµ´¹ï±M·~¡AÅwªï¨Ó¹q | ¤£½×±z·j´M¥ô¦ó¸ê°T¡A³£¯àÅý§A¥i¥H«Ü¤è«K¦a§ä¸ê®Æ ºë·Ç§ë©ñ«È¸s¡A·m·~ÁZ³Ìµ¹¤O¡A³t¬¢¿Ô¸ß |
[±Ð¾Ç]big5 Âà utf-8 ¤§¤èªk |
©ÐªF¡G¤pD µoªí®É¶¡¡G2010-06-01 | [ÀËÁ|] |
³Ìªñ¦]¬°n¼g¤@ÓÀ³¥Îµ{¦¡¡A¥L¥²¶·§âºô¶¶Ç°e¹L¨Óªº¸ê®ÆÂର utf-8 ¦A³B²z¡A ¤@¯ë big5 Âà utf-8 ¥Î iconv ¨ç¼Æ´N¥i¥H³B²z¡A¦ý¦³¤@ºØ±¡§Î¡A´N¬O¦pªG big5 ¦r¦ê¤¤¦pªG¦³ ´NµLªkÂà´« ©Ò¥H§Ú¯S§O¼g¤F¤@ÓÂà´«µ{¦¡ function big5_2_utf8($big5_str) { $sw[\"¹ù\"]=\"¹ù\"; $sw[\"ùÖ\"]=\"ùÖ\"; $sw[\"ùÛ\"]=\"ùÛ\"; $sw[\"ùØ\"]=\"ùØ\"; $sw[\"ùÙ\"]=\"ùÙ\"; $sw[\"ùÚ\"]=\"ùÚ\"; $sw[\"ù×\"]=\"ù×\"; $sw[\"ùÜ\"]=\"ùÜ\"; $sw[\"ùÝ\"]=\"ùÝ\"; $sw[\"ùÞ\"]=\"ùÞ\"; $sw[\"ùß\"]=\"ùß\"; $sw[\"ùà\"]=\"ùà\"; $sw[\"ùá\"]=\"ùá\"; $sw[\"ùâ\"]=\"ùâ\"; $sw[\"ùã\"]=\"ùã\"; $sw[\"ùä\"]=\"ùä\"; $sw[\"ùå\"]=\"ùå\"; $sw[\"ùæ\"]=\"ùæ\"; $sw[\"ùç\"]=\"ùç\"; $sw[\"ùè\"]=\"ùè\"; $sw[\"ùé\"]=\"ùé\"; $sw[\"ùê\"]=\"ùê\"; $sw[\"ùë\"]=\"ùë\"; $sw[\"ùì\"]=\"ùì\"; $sw[\"ùí\"]=\"ùí\"; $sw[\"ùî\"]=\"ùî\"; $sw[\"ùï\"]=\"ùï\"; $sw[\"ùð\"]=\"ùð\"; $sw[\"ùñ\"]=\"ùñ\"; $sw[\"ùò\"]=\"ùò\"; $sw[\"ùó\"]=\"ùó\"; $sw[\"ùô\"]=\"ùô\"; $sw[\"ùõ\"]=\"ùõ\"; $sw[\"ùö\"]=\"ùö\"; $sw[\"ù÷\"]=\"ù÷\"; $sw[\"ùø\"]=\"ùø\"; $sw[\"ùù\"]=\"ùù\"; $sw[\"ùÝ\"]=\"ùÝ\"; $sw[\"ùß\"]=\"ùß\"; $sw[\"ùã\"]=\"ùã\"; $sw[\"ùå\"]=\"ùå\"; $sw[\"¢i\"]=\"¢i\"; $sw[\"£á\"]=\"£á\"; $sw[\"¡þ\"]=\"¡þ\"; $len=strlen($big5_str); $un=\'\'; for ($i=0;$i<$len;$i++) { $s =substr($big5_str,$i,1); $s1 =substr($big5_str,$i,2); $sbit=ord($s); if ($sbit < 0x80) { $un.=$s; } else { $new_word=iconv(\"BIG5\",\"UTF-8\",$s1); if(!$new_word){ if($sw[$s1]) $new_word=$sw[$s1]; } if($new_word!=\'\'){ $un.=$new_word; $i++; } } } $s=\'\'; while(strlen($un)>0){ $p=strpos($un,\"\"); if ($p===false) { $s.=$un; return $s; } else{ if ($p!=0){ $s.=substr($un,0,$p); $un=substr($un,$p); } $p=strpos($un,\";\"); if ($p===false){ $s.=$un; return $s; } else{ $code=substr($un,2,$p-2); $un=substr($un,$p+1); if (strcasecmp($code{0},\"x\")==0){ $code=hexdec(substr($code,1)); } else{ $code=intval($code); } if($code <= 0x7f){ $s.=chr($code); } elseif($code <= 0x7ff){ $s.=chr(($code >> 6) | 0xc0); $s.=chr(($code % 0x40) | 0x80); } elseif($code <= 0xffff){ $s.=chr( ($code >> 12) | 0xe0); $s.=chr((($code >> 6) % 0x40) | 0x80); $s.=chr( ($code % 0x40) | 0x80); } elseif($code <= 0x10ffff){ $s.=chr( ($code >> 18) | 0xf0); $s.=chr((($code >> 12) % 0x40) | 0x80); $s.=chr((($code >> 6) % 0x40) | 0x80); $s.=chr( ($code % 0x40) | 0x80); } } } } return $s; } |
1 ¼Ó¦í¤á¡G¤p¿ß µoªí®É¶¡¡G2010-06-01 | [ÀËÁ|] |
¦]¬°¥Ø«e½×¾Âªº½s½X¬O Big-5 ¡A¬°¤F¸òºñ¬Éªº«K§Q¶W°Ó¥I¶O¾÷¨îµ²¦X¡A¦Ó¤£¥©¡A¥Lªº½s½X¬O UTF-8¡A©Ò¥H§Ú¶Ç¹L¥hªº°Ñ¦Ò¥þÅܦ¨¶Ã½X¡A©Ò¥H§Ú¤£±o¤w¥u¦n¼g¤@ÓÂà½X¶±¡A¦³»Ý¨Dªº¥i¥H°Ñ¦Ò¨Ï¥Î.. $pay_sob=iconv('BIG5','UTF-8',$pay_sob); $pay_name=iconv('BIG5','UTF-8',$pay_name); ?> �ݷ|�N�|�޾ɱz�ܫK�Q�W�ӥI�O�e���A�Ð@�ߵ��J... |
2 �Ӧ���G���_ �o���ɶ��G2010-06-01 | [���|] |
�̪�g�{���|�Ψ� utf8 �� big5�A���ӷQ����iconv�N�n�F ���L�ڦb�ϥ�iconv�A�Nutf8��big5�ɴN�X�{�@�Ӱ��D�A�N�O�u�n�J��utf8��big5�A�S��������big5�X���ÉÔ´N�����p�F�A�쥻�H���N���Ӧr�S�X�{�A���G�O����������big5�X�ᥦ�O�H�᪺�q�q�����F�A���M�o�U�l�N�����F�C �̫�ڥu�n�@�Ӧr�@�Ӧr��A�M��J��S���������X�N��"��"�N���A���M�l���F�į�A���O�o�T�O�F���T�ʡC ����ѦҦ� http://203.68.102.46/online_book/content.php?chapter_sn=173 �P�� JENY's �ƻs�{�� //�v�r�ഫutf8�r�ꬰbig5 function utf8_2_big5($utf8_str) { $i=0; $len = strlen($utf8_str); $big5_str=""; for ($i=0;$i<$len;$i++) { $sbit = ord(substr($utf8_str,$i,1)); if ($sbit < 128) { $big5_str.=substr($utf8_str,$i,1); } else if($sbit > 191 && $sbit < 224) { $new_word=iconv("UTF-8","Big5",substr($utf8_str,$i,2)); $big5_str.=($new_word=="")?"��":$new_word; $i++; } else if($sbit > 223 && $sbit < 240) { $new_word=iconv("UTF-8","Big5",substr($utf8_str,$i,3)); $big5_str.=($new_word=="")?"��":$new_word; $i+=2; } else if($sbit > 239 && $sbit < 248) { $new_word=iconv("UTF-8","Big5",substr($utf8_str,$i,4)); $big5_str.=($new_word=="")?"��":$new_word; $i+=3; } } return $big5_str; } �]���ӤH�ݨD�A�� utf-8 �� big5 �ɡA�������쪺�r�A�ڷQ�n��� $len = strlen($utf8_str); $big5_str=""; for ($i=0;$i<$len;$i++) { $s =substr($utf8_str,$i,1); $s1=substr($utf8_str,$i+1,1); $s2=substr($utf8_str,$i+2,1); $s3=substr($utf8_str,$i+3,1); $sbit=ord($s); if ($sbit < 0x80) { $big5_str.=$s; } else if($sbit >= 0xc0 && $sbit < 0xe0) { $new_word=iconv("UTF-8","Big5",substr($utf8_str,$i,2)); $big5_str.=$new_word?$new_word: ''.(((ord($s) & 0x1f) * 0x40) + (ord($s1) & 0x3f)).'' $i++; } else if($sbit >= 0xe0 && $sbit < 0xf0) { $new_word=iconv("UTF-8","Big5",substr($utf8_str,$i,3)); $big5_str.=$new_word?$new_word: ''.(((ord($s) & 0x0f) * 0x1000) + ((ord($s1) & 0x3f) * 0x40) + (ord($s2) & 0x3f)).'' $i+=2; } else if($sbit >= 0xf0 && $sbit < 0xf8) { $new_word=iconv("UTF-8","Big5",substr($utf8_str,$i,4)); $big5_str.=$new_word?$new_word: ''.(((ord($s) & 0x07) * 0x40000) + ((ord($s1) & 0x3f) * 0x1000) + ((ord($s2) & 0x3f) * 0x40) + (ord($s3) & 0x3f)).'' $i+=3; } } return $big5_str; } [/code] [/sell] |