phpÖÐmb_convert_encoding ºÍ iconv µÄÇø±ð
mb_convert_encodingÕâ¸öº¯ÊýÊÇÓÃÀ´×ª»»±àÂëµÄ¡£ÔÀ´Ò»Ö±¶Ô³ÌÐò±àÂëÕâÒ»¸ÅÄî²»Àí½â£¬²»¹ýÏÖÔÚºÃÏñÓе㿪ÇÏÁË¡£
²»¹ýÓ¢ÎÄÒ»°ã²»»á´æÔÚ±àÂëÎÊÌ⣬ֻÓÐÖÐÎÄÊý¾Ý²Å»áÓÐÕâ¸öÎÊÌâ¡£±ÈÈçÄãÓÃZend Studio»òEditplusд³ÌÐòʱ£¬ÓõÄÊÇgbk±àÂ룬Èç¹ûÊý¾ÝÐèÒªÈëÊý¾Ý¿â£¬¶øÊý¾Ý¿âµÄ±àÂëΪutf8ʱ£¬Õâʱ¾ÍÒª°ÑÊý¾Ý½øÐбàÂëת»»£¬²»È»½øµ½Êý¾Ý¿â¾Í»á±ä³ÉÂÒÂë¡£
mb_convert_encodingµÄÓ÷¨¼û¹Ù·½£º
http://cn.php.net/manual/zh/function.mb-convert-encoding.php
×öÒ»¸öGBK To UTF-8
< ?php
header("content-Type: text/html; charset=Utf-8");
echo mb_convert_encoding("妳係ÎÒµÄÓÑ×Ð", "UTF-8", "GBK");
?>
ÔÙÀ´¸öGB2312 To Big5
< ?php
header("content-Type: text/html; charset=big5");
echo mb_convert_encoding("ÄãÊÇÎÒµÄÅóÓÑ", "big5", "GB2312");
?>
²»¹ýҪʹÓÃÉÏÃæµÄº¯ÊýÐèÒª°²×°µ«ÊÇÐèÒªÏÈenable mbstring À©Õ¹¿â¡£
PHPÖеÄÁíÍâÒ»¸öº¯ÊýiconvÒ²ÊÇÓÃÀ´×ª»»×Ö·û´®±àÂëµÄ£¬ÓëÉϺ¯Êý¹¦ÄÜÏàËÆ¡£
ÏÂÃ滹ÓÐһЩÏêϸµÄÀý×Ó£º
iconv — Convert string to requested character encoding
(PHP 4 >= 4.0.5, PHP 5)
mb_convert_encoding — Convert character encoding
(PHP 4 >= 4.0.6, PHP 5)
Ó÷¨£º
string mb_convert_encoding ( string str, string to_encoding [, mixed from_encoding] )
ÐèÒªÏÈenable mbstring À©Õ¹¿â£¬ÔÚ php.iniÀォ; extension=php_mbstring.dll Ç°ÃæµÄ ; È¥µô
mb_convert_encoding ¿ÉÒÔÖ¸¶¨¶àÖÖÊäÈë±àÂ룬Ëü»á¸ù¾ÝÄÚÈÝ×Ô¶¯Ê¶±ð,µ«ÊÇÖ´ÐÐЧÂʱÈiconv²îÌ«¶à£»
string iconv ( string in_charset, string out_charset, string str )
×¢Ò⣺µÚ¶þ¸ö²ÎÊý£¬³ýÁË¿ÉÒÔÖ¸¶¨Òª×ª»¯µ½µÄ±àÂëÒÔÍ⣬»¹¿ÉÒÔÔö¼ÓÁ½¸öºó׺£º//TRANSLIT ºÍ //IGNORE£¬ÆäÖÐ //TRANSLIT »á×Ô¶¯½«²»ÄÜÖ±½Óת»¯µÄ×Ö·û±ä³ÉÒ»¸ö»ò¶à¸ö½üËƵÄ×Ö·û£¬//IGNORE »áºöÂÔµô²»ÄÜת»¯µÄ×Ö·û£¬¶øĬÈÏЧ¹ûÊÇ´ÓµÚÒ»¸ö·Ç·¨×Ö·û½Ø¶Ï¡£
Returns the converted string or FALSE on failure.
ʹÓãº
·¢ÏÖiconvÔÚת»»×Ö·û”—”µ½gb2312ʱ»á³ö´í£¬Èç¹ûûÓÐignore²ÎÊý£¬ËùÓиÃ×Ö·ûºóÃæµÄ×Ö·û´®¶¼ÎÞ·¨±»±£´æ¡£²»¹ÜÔõôÑù£¬Õâ¸ö”—”¶¼ÎÞ·¨×ª»»³É¹¦£¬ÎÞ·¨Êä³ö¡£ ÁíÍâmb_convert_encodingûÓÐÕâ¸öbug.
Ò»°ãÇé¿öÏÂÓà iconv£¬Ö»Óе±Óöµ½ÎÞ·¨È·¶¨Ô±àÂëÊǺÎÖÖ±àÂ룬»òÕßiconvת»¯ºóÎÞ·¨Õý³£
Ïà¹ØÎĵµ£º
²Ù×÷ϵͳ: windows xp
php°æ±¾:5.2.5 http://www.php.net/downloads.php
Apache http server °æ±¾:2.2.6http://httpd.apache.org/download.cgi
Mysql°æ±¾: 6.0.3http://dev.mysql.com/get/Downloads/MySQL-6.0
1.apacheµÄ°²×°:
1)Ë«»÷apache_2.2.6-win32-x86-no_ssl.msiͼ±ê£¬Æô¶¯apache°²×°³ÌÐò£»
2£©°²×°ÒÔÒ»¸ö»¶Ó ......
·½·¨Ò»£º½¨Ò»¸öÆ´Òô±í t_cosler £¬´æ·Åÿ¸ö×Öĸ¿ªÍ·µÄµÚÒ»¸öºº×ֵıàºÅºÍ×îºóÒ»¸öºº×ֵıàºÅ¡£
BatchFile code+------+--------+-------+
| f_PY | cBegin | cEnd |
+------+--------+-------+
| A | 45217 | 45252 | & ......
Ò»¡¢ÏµÍ³Ô¼¶¨
¡¡¡¡»·¾³Èí¼þÏÂÔغó´æ·ÅλÖãºX:\Server_Tools
¡¡¡¡»·¾³Èí¼þ°²×°Î»ÖãºX:\Server_Core
¡¡¡¡PHP°²×°Î»ÖãºX:\Server_Core\PHP
¡¡¡¡MySQL°²×°Î»ÖãºX:\Server_Core\MySQL
¡¡¡¡IISÍøÕ¾Õ¾µã¸ùĿ¼£ºX:\wwwroot
¡¡¡¡MySQL Êý¾Ý¿âλÖãºX:\Database
¡¡¡¡Php.ini´æ·ÅλÖãºX:\Windows\php.ini
¡¡¡¡My.ini ´æ· ......
ÓÉÓÚÏÖÔÚµÄä¯ÀÀÆ÷ÒѾ¿ÉÒÔʶ±ð¸ñʽΪtxtµÄÎĵµ¸ñʽ£¬ËùÒÔÈç¹ûÖ»ÊǸøtxtÎĵµ×öÒ»¸öÎÄ×ÖÁ´½ÓµÄ»°£¬¿ÉÄÜÖ»ÊÇ´ò¿ªÒ»¸öд°¿ÚÏÔʾtxtÎļþµÄÄÚÈÝ£¬²¢²»ÄÜʵÏÖµã»÷ÏÂÔصÄÄ¿µÄ¡£We have to do something else.
µ±È»Õâ¸öÎÊÌâµÄ½â¾ö°ì·¨Ò²¿ÉÒÔÊÇÄ㽫ÄãµÄtxtÎļþ¸ÄÃûΪä¯ÀÀÆ÷²»ÈÏʶµÄÎļþ£¬±ÈÈçrar,ÕâÑùµÄ»°µã»÷£¬ ......
<?
//------------------------
// PHPÄÚÖÃ×Ö·û´®º¯ÊýʵÏÖ
//------------------------
//×Ö·û´®³¤¶È
function strlen ($str)   ......