dz̸ÓÃphp¶Ôunicodeתutf 8±àÂë
(IT°ØÀͼ Ô´´ÎÄÕÂ)Èç¹ûÖ»ÊÇunicodeתutf-8±àÂëµÄËã·¨£¬ÍøÉϵ½´¦¶¼ÊÇÁË£¬²»¹ýºÜ¶àÈËÒ²ÊÇÄã³ÎÒ£¬ÎÒ³Ä㣬¸ù±¾¾Í²»Àí½âwhyºÍdo£¬±¾ÎijýÁ˸ø³ö×î¼òµ¥µÄphp¶Ôunicodeתutf-8±àÂ뺯ÊýÖ®Í⣬ҲÉîÈëÌÖÂÛÁËÕâÁ½ÖÖ±àÂëµÄ¹Øϵ£¬Àí½âºÃÁ˻ᷢÏÖÍøÉÏһЩ¾ÉµÄ¶«Î÷£¬ÊÇÑÏÖضàÓà¼æ¹ýÆڵģ¬ÒòΪ´Óutf-8Á÷ÐпªÊ¼µ½ÏÖÔÚ£¬ÔçÒѾÓÉÔÀ´Áù×ֽڿɱä±àÂ뵽ʵ¼ÊÍêÈ«¾ÓÓÚunicode(UCS-2)µÄÎȶ¨½×¶Î¡£
unicode±àÂëÊÇʵÏÖutf-8ÓëgbϵÁбàÂë(gb2312¡¢gbk¡¢gb18030)ת»»µÄ»ù´¡£¬ËäÈ»ÎÒÃÇÒ²¿ÉÒÔÖ±½Ó×öÒ»¸öutf-8µ½ÕâЩ±àÂëµÄ¶ÔÕÕ±í£¬µ«ºÜÉÙÓÐÈË»áÕâô×ö£¬ÒòΪutf-8µÄ¿É±ä±àÂë¾ßÓв»È·¶¨ÐÔ£¬Òò´ËÒ»°ãÇé¿öʹÓö¼ÊÇunicodeÓëgb±àÂëµÄ¶ÔÕÕ±í£¬unicode(UCS-2)ʵ¼ÊÉÏÊÇutf-8µÄ»ù´¡±àÂ룬utf-8Ö»ÊÇËüµÄÒ»ÖÖʵÏÖ¶øÒÑ£¬Á½Õß´æÔÚÏÂÃæµÄ¶ÔÓ¦¹Øϵ£º
Unicode·ûºÅ·¶Î§ | UTF-8±àÂ뷽ʽ
u0000 0000 - u0000 007F | 0xxxxxxx
u0000 0080 - u0000 07FF | 110xxxxx 10xxxxxx
u0000 0800 - u0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx
ÓÉÓÚÄ¿Ç°utf-8ʹÓõÄ×Ö·û¶¼ÊǾÓÓÚUCS-2µÄ£¬Òò´Ë¶ÔÓÚ4-6×Ö½Ú±àÂëµÄÇé¿öÊDz»±Ø¿¼Âǵģ¬Í¬ÑùµØ£¬ÔÚ·´Ïòת»»µÄʱºò£¬Èç¹û³öÏÖËÄ×Ö½ÚÒÔÉϵÄutf-8×Ö·û£¬¿ÉÒÔÖ±½ÓÊÓΪÂÒÂëºöÂÔµô»òתΪunicodeʵÌåÐÎʽ("&#long int;"ÐÎʽ)£¬È»ºó½»¸øä¯ÀÀÆ÷»òÏà¹Ø½âÎö³ÌÐòÈ¥´¦Àí£¬ÓÃphp°ÑunicodeתΪutf-8±àÂëµÄËã·¨ÈçÏ£º
/*
* ²ÎÊý $c ÊÇunicode×Ö·û±àÂëµÄintÀàÐÍÊýÖµ£¬Èç¹ûÊÇÓöþ½øÖƶÁÈ¡µÄÊý¾Ý£¬ÔÚphpÖÐͨ³£ÒªÓà hexdec(bin2hex( $bin_unichar )) ÕâÑùת»»
*/
function uni2utf8( $c )
{
if ($c < 0x80)
{
$utf8char = chr($c);
}
else if ($c < 0x800)
{
$utf8char = chr(0xC0 | $c >> 0x06).chr(0x80 | $c & 0x3F);
}
else if ($c < 0x10000)
{
$utf8char = chr(0xE0 | $c >> 0x0C).chr(0x80 | $c >> 0x06 & 0x3F).chr(0x80 | $c & 0x3F);
}
//ÒòΪUCS-2Ö»ÓÐÁ½×Ö½Ú£¬ËùÒÔºóÃæµÄÇé¿öÊDz»¿ÉÄܳöÏֵģ¬ÕâÀïÖ»ÊÇ˵Ã÷unicode HTMLʵÌå±àÂëµ
Ïà¹ØÎĵµ£º
<?php
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:filename=php100.xls");
/* echo "A1\t B1\t C1\n";
echo "A1\t B1\t C1\n";
echo "A1\t B1\t C1\n";
*/
?>
<!--*********************************************±¨±í***************************************** ......
ÎÒÏÖÔÚÓÐÕâÑùÒ»¸öÐèÇ󣬻òÐí×öc++³ÌÐòµÄ×ö¹ýÕâÑùµÄÍæÒâ¶ù£¬ÎÒÏÖÔÚÏëÓÃphpÀ´ÊµÏÖ£¬´ÓûÅöµ½ÕâÑùµÄÇé¿ö£¬ËùÒÔÓеãã¡£»¹Çë¸ßÈËÖ¸µãŶ£¬²»Ê¤¸Ð¼¤£¬Çë²é¿´ÎÒÉÏ´«µÄ½Øͼ£¬¸´ÖƹýÀ´£¬ÑùʽÂÒÁË¡£
ÃèÊöÒ»ÏÂÐèÇó°É£º¾ÍÊÇÔÚÎı¾ÀïÃæÓÃÖƱí·û»³ö±í¸ñÊ ......
°ÑphpÊý¾Ý»òÖµ´«µÝ¸øjs
£ººÜ¼òµ¥£¬Ö±½ÓÔÚjsÖÐʹÓÃphp´úÂ룬»ì±à¼´¿É¡£
°ÑjsÊý¾Ý´«µÝ¸øphp
£º¿ÉÒÔʹÓôò¿ªÐ´°¿ÚµÄ·½Ê½£¬Í¨¹ýurlµØÖ·°ÑÊý¾Ý´«µÝ¹ýÈ¥¡£Ò²¿ÉÒÔʹÓÃajax£¬Í¨¹ýget»òpost´«µÝ¸øphp£¬Ò²¿ÉÒÔ±£´æcookieÈÃphpÀ´¶Á¡£
ÔÚ´«µÝÊý¾Ý¹ý³ÌÖпÉÄÜÓöµ½ÖÐÎıàÂë
ÎÊÌ⣬¿ÉÒÔͳһ±àÂ뷽ʽΪjsµÄescape£¬unescape£¬Ò²¿ÉÒÔÍ³Ò ......
$URL
=‘
http
:
//xxx.xxx.xxx.xx/xx/xxx/top.php';
$post_data
[
'
clientname
'
]
=
"
test08
"
;
$post_data
[
'
clientpasswd
'
]
=
"
test08
"
;
$post_data
[
'
submit
'
]
=
"
¥í¥°¥¤¥ó
"
;
$referrer
=
""
;
// ......