±M·~¾Tªùµ¡¡BÁë³yªù³]p¤Î¦w¸Ë »ù®æ«K©y¡B«~½è¦n¡B³]p¨Î¡Aȱo±z«H¿à | ºë°µ°ªÃø«×¨¾¤ô§ìº|/¾ÀÀù/ªoº£µ¥¤uµ{ ³d¥ô¬I¤u¡B¦X¬ù«O©T¡I |
[Âà¶K]MySQL©Mphp±Ä¥ÎUTF8ªº¸Ô²Ó¤èªk |
©ÐªF¡G·s¤â µoªí®É¶¡¡G2007-03-10 |
¤p§Ì´X¤Ñ¨Óµ¹MySQL©Mphp¥þ±±Ä¥ÎUTF8·d±o ÀY©ü¸£µÈ, ²{¦bÁ`ºâ·d²M·¡¤F, ¦¨¥\Âà´«¬°UTF8. ¨Ò¦p: ³\ ¥\ »\ ùÖ ù× ùØ ùÙ ùÚ ùÛ ùÜ ³o¨Ç¦r¤w§¹¥þ°ÝÃD¤F. ²{Á`µ²¤@¤Uµ¹¤j¥ë°Ñ¦Ò. [¦p»ÝÂà¸ü,½Ðª`©ú¥X³B] ****** ºô ¯¸ ¥þ ± ±Ä ¥Î UTF-8 ¤èªk. ****** 1. ¥Î vi /etc/httpd/conf/httpd.conf ³]©wApache¤¤ªº»y¨t¬° (°O±orestart) AddDefaultCharset UTF-8 2. ¥Î vi /etc/php.ini ³]©wphp¤¤ªº»y¨t¬° (°O±orestart) default_charset = "utf-8" 3. ¥Î vi /etc/my.cnf ³]©wMySQL¤¤ªº»y¨t¬° (°O±orestart) [mysqld] init_connect='SET NAMES utf8' default-character-set=utf8 [client] default-character-set = utf8 4. «Ø¥ß¸ê®Æ®w®É¿ï¾Ü»y¨t: (°O±o²M°£DB Cache) DROP DATABASE IF EXISTS `aa`; CREATE DATABASE `aa` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; USE `aa`; CREATE TABLE IF NOT EXISTS `aat` ( `id` char(1) NOT NULL default '1', `myStr` varchar(200) default NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; 5. ¥ÎUltraEdit(v11.20aª©) Âà´«©Ò¦³ANSI®æ¦¡ªºphpÀÉ®×Âà¤Æ¬°UTF-8®æ¦¡: File --> Conversions --> ASCII to UTF-8 (Unicoding Editing) ( ¦bUltraEdit¤¤«öAdvanced --> configuration --> File Handling --> Unicode/UTF-8 Detection --> ç¿ïAuto detect utf-8 files ) ¦p¦³»Ýn®É,¥i°õ¦æRemove BOM.php. ·í¥ÎWinXPªºNotepad±NphpÀÉ¥ÑANSIÂରUTF-8®É, ¦]ÀÉÀY¦³BOM,·|¤Þ°_±Æª©°ÝÃD,¬G¥²¶·²¾°£,°õ¦æRemove BOM.php§Y¥i¦Û°Ê²¾°£. Remove BOM.php¥i¥Ñ¥H¤Uºô§}¤U¸ü: http://www.hoyo.idv.tw/hoyoweb/document/view.php?sid=13&author=hoyo&status=view 6. ¦bphpÀɤ¤¥²¶·¥[¤J: 7. ¦b³s±µDBªºÀɤ¤¥²¶·¥[¤J3¦æmysql_query¤~ok: $host="localhost"; $DBname="aa"; $user= "root"; $passwd = ""; $link = mysql_connect($host,$user,$passwd) or die ("Fail"); $db = mysql_select_db($DBname, $link) or die ("Fail"); // n¦b¯u¥¿query DB¨ú¥X¸ê®Æ«e,¥[¤J¥H¤U3¦æ mysql_query("SET NAMES 'utf8'"); mysql_query("SET CHARACTER_SET_CLIENT=utf8"); mysql_query("SET CHARACTER_SET_RESULTS=utf8"); $sql = "select * from aat where crid='1'"; $rows = mysql_query($sql); 8. ¦bphpÀɤ¤, ¦p¦³»Ýn¶·ª`·N: [Optional] ¹B¥Îhtmlentities©Mhtmlspecialchars®É,n¦ü¦p¤U: $chars = htmlentities($chars,ENT_QUOTES,"UTF-8"); $chars = htmlspecialchars($chars,ENT_QUOTES,"UTF-8"); ¨Ã¥B¦bÅã¥Ü«en¥Î $chars = html_entity_decode($chars,ENT_QUOTES,"UTF8"); ¦p¦³¥Î¹Laddslashes()©Îmysql_real_escape_string()°O±o¥Î¥H¤U: $chars = stripslashes($chars); ¦p¦³»Ýn¥i¥H¥Î¥H¤Ufunction±N¤£¦P½s½XÂà´«: $chars = iconv('Big5','UTF-8',$chars); //¥ÑBig5ÂରUTF-8 |
|
©m¦W¡G | |||
§G§i¤º®e¡G | |||
¨ä¥L¿ï¶µ: | |||
|