µ¡Ã®¡B¾À¯È¡B¾À¶K±M·~»s§@
´Ú¦¡¿W¯S¡Aºô¤Í¤@­P¦nµû
¼s§i©ÛµP³q°¨±í¡B³q¤ôºÞ¡B©â¤ôªÎ¡B©â¤ÆÁT¦À
»ù¿ú¤½¹D¡A24H§Ö³tªA°È

­º­¶  ¡E  tw ½×¾Â ¡E µ{¦¡³]­p°Q½×     ¡E 

[±Ð¾Ç]big5 Âà utf-8 ¤§¤èªk

©ÐªF¡G¤p­D
µ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;
}






  • ÃÙ§Uºô¯¸       

    ¼s§Q¤£°Ê²£-·sªO¯S°Ï«ü¦W«×³Ì°ª¡B­È±o±z«H¿àªº¦n©Ð¥ò
    ±zªº¦«¥I,¼s§Q¥Î¤ß¬°±zªA°È
    ¼s§Q¤£°Ê²£-ªO¾ô¦b¦a¥Í®Ú³Ì¹ê¦b--·sªO¯S°Ï«ü¦W«×³Ì°ª¡B­È±o±z«H¿àªº¦n©Ð¥ò
    §¹¾ã©Ð°T¡A©Ð«Î¡B©±­±¼öªùºë¿ïª«¥ó¡A¼s§Q¤£°Ê²£ Àu½è¥ò¤¶¡A©Ð«Î¯²¸î¡B¶R½æ¸ê°T³z©ú¡A¥æ©ö¯u¦w¤ß¡I

  • 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]



    �@�@ 2 �H�^���@�@��ܭ��� �i��1 ���j 

    �m�W�G
    �G�i���e�G