引用 | 編輯
goldenbowl
2006-07-31 22:38 |
樓主
▼ |
||
x0
小弟日前下載了一個Flash+php mysql的程式已經成功裝上了,但flash不支援中文字體..後來在大陸源碼站有看到修改過的版本flash可以顯示簡體中文字..小弟比較英文版以及大陸版的檔案..發現大陸版多了一個檔案"gb2312.txt"以及其中一個script.php檔內容不同如下: 請問各位先進,小弟要如何修改才能達成繁體中文在flash顯示的效果呢?...謝謝 複製程式 英文版script.php: <?php require_once(''Connections/poll.php''); ?> <?php mysql_select_db($database_poll, $poll); $query = "SELECT * FROM flash_poll WHERE flash_poll.status=1"; $result = mysql_query($query,$poll) or die ("Error in query: $query. " . mysql_error()); if (mysql_num_rows($result) > 0) { while($row = mysql_fetch_row($result)) { echo "&ID=" ;echo $row[0];echo "&"; echo "question=";echo $row[1];echo "&"; echo "answer_no="; echo $row[2];echo "&"; for ($i=3;$i<3+$row[2];$i++) {echo "answer";echo $i-2;echo "=";echo $row[$i];if ($i<2+$row[2]){echo "&";}}; echo "&skin=".$row[20]."&"; } } ?> 複製程式 大陸簡體版script.php: <? function u2utf8($c) { for($i=0;$i<count($c);$i++) $str=""; if ($c < 0x80) $str.=$c; elseif ($c < 0x800) { $str.=(0xC0 | $c>>6); $str.=(0x80 | $c & 0x3F); } elseif ($c < 0x10000) { $str.=(0xE0 | $c>>12); $str.=(0x80 | $c>>6 & 0x3F); $str.=(0x80 | $c & 0x3F); } elseif ($c < 0x200000) { $str.=(0xF0 | $c>>18); $str.=(0x80 | $c>>12 & 0x3F); $str.=(0x80 | $c>>6 & 0x3F); $str.=(0x80 | $c & 0x3F); } return $str; } function gb2utf8($gb) { if(!trim($gb)) return $gb; $filename="gb2312.txt"; $tmp=file($filename); $codetable=array(); while(list($key,$value)=each($tmp)) $codetable[hexdec(substr($value,0,6))]=substr($value,7,6); $ret=""; $utf8=""; while($gb) { if (ord(substr($gb,0,1))>127) { $thi=substr($gb,0,2); $gb=substr($gb,2,strlen($gb)); $utf8=u2utf8(hexdec($codetable[hexdec(bin2hex($thi))-0x8080])); for($i=0;$i<strlen($utf8);$i+=3) $ret.=chr(substr($utf8,$i,3)); } else { $ret.=substr($gb,0,1); $gb=substr($gb,1,strlen($gb)); } } return $ret; } require_once(''Connections/poll.php''); ?> <?php mysql_select_db($database_poll, $poll); $query = "SELECT * FROM flash_poll WHERE flash_poll.status=1"; $result = mysql_query($query,$poll) or die ("Error in query: $query. " . mysql_error()); if (mysql_num_rows($result) > 0) { while($row = mysql_fetch_row($result)) { echo "&ID=" ;echo $row[0];echo "&"; echo "question=";echo gb2utf8($row[1]);echo "&"; echo "answer_no="; echo $row[2];echo "&"; for ($i=3;$i<3+$row[2];$i++) {echo "answer";echo $i-2;echo "=";echo gb2utf8(trim($row[$i]));if ($i<2+$row[2]){echo "&";}}; echo "&skin=".$row[20]."&"; } } ?> x0
|