小弟日前下载了一个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]."&";
}
}
?>