¤@±i«O³æ»´ÃP¨É¦³¤H¥Í¦U¶¥¬q·ÀI«O»Ù ³q³qÀ°±z³Wµe¦n | ![]() | ±zÁÙ´±¨Ï¥Îº¡¬OÅܺزӵߪº¹q¸Ü³q¸Ü¶Ü ½Ð©w´Á¹q¸Ü²M¼ä®ø¬r, |
[±Ð¾Ç]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¥un¹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§Ú·Qn§ï¥Î $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] |