Àu¨}·h®a¤½¥q¡A³ø»ù¹ê¦b
24H¥þ¬Ù·h¾EªA°È¡A§K¶O¦ô»ù¡C
²M¼ä¤½¥qªoº£±M®a20¦h¦~¦Ñ¸gÅç¡A±M·~ªºªoº£¤uµ{
¸ËæC³]­p¤§­º¿ï¡A§K¶O¦ô»ù

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

[Âà¶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Åã¥Ü«e­n¥Î
$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



  • ÃÙ§Uºô¯¸       

    ¼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
    ¼s§Q¤£°Ê²£-·sªO¯S°Ï«ü¦W«×³Ì°ª¡B­È±o±z«H¿àªº¦n©Ð¥ò
    ±zªº¦«¥I,¼s§Q¥Î¤ß¬°±zªA°È



  • ¡@¦@ 0 ¤H¦^À³

    ©m¦W¡G
    §G§i¤º®e¡G
    ¨ä¥L¿ï¶µ: