广告广告
  加入我的最爱 设为首页 风格修改
首页 首尾
 手机版   订阅   地图  繁体 
您是第 4179 个阅读者
 
发表文章 发表投票 回覆文章
  可列印版   加为IE收藏   收藏主题   上一主题 | 下一主题   
goldenbowl
数位造型
个人文章 个人相簿 个人日记 个人地图
小人物
级别: 小人物 该用户目前不上站
推文 x1 鲜花 x7
分享: 转寄此文章 Facebook Plurk Twitter 复制连结到剪贴簿 转换为繁体 转换为简体 载入图片
推文 x0
[PHP][讨论] 请问如何修改为繁体字体
小弟日前下载了一个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 回到顶端 [楼 主] From:台湾中华电信 | Posted:2006-07-31 22:38 |
keigo
个人头像
个人文章 个人相簿 个人日记 个人地图
初露锋芒
级别: 初露锋芒 该用户目前不上站
推文 x0 鲜花 x71
分享: 转寄此文章 Facebook Plurk Twitter 复制连结到剪贴簿 转换为繁体 转换为简体 载入图片

script.php应该只是要把字串转成utf8吧...
基本上直接做的话 不太会有问题的...
http://38.114.39.196/...jcjonny/


欢迎各位参观小弟的Blog男丁格尔's 脱壳玩
献花 x0 回到顶端 [1 楼] From:台湾中华电信 | Posted:2006-08-01 01:30 |

首页  发表文章 发表投票 回覆文章
Powered by PHPWind v1.3.6
Copyright © 2003-04 PHPWind
Processed in 0.020201 second(s),query:16 Gzip disabled
本站由 瀛睿律师事务所 担任常年法律顾问 | 免责声明 | 本网站已依台湾网站内容分级规定处理 | 连络我们 | 访客留言