最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

圖象函數(shù)中的中文顯示

 更新時間:2006年10月09日 00:00:00   作者:  
把GB碼轉(zhuǎn)換到UTF8,php中TTF支持UTF8編碼的非ASCII字符輸出.在分析這段代碼之后,發(fā)現(xiàn)可以實現(xiàn)中文與ASCII混合輸出圖象,這樣在我們操作圖象函數(shù)時可以更方便.
代碼如下:
<?

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);

$utf8="";
while($gb)
{
if (ord(substr($gb,0,1))>127)
{
$this=substr($gb,0,2);
$gb=substr($gb,2,strlen($gb)-2);
$utf8.=u2utf8(hexdec($codetable[hexdec(bin2hex($this))-0x8080]));
}
else
{
$this=substr($gb,0,1);
$gb=substr($gb,1,strlen($gb)-1);
$utf8.=u2utf8($this);
}
}

/*$ret="";
for($i=0;$i<strlen($utf8);$i+=3)
$ret.=chr(substr($utf8,$i,3));

return $ret;*/

return $utf8;
}
function u2utf8($c)
{
/*for($i=0;$i<count($c);$i++)*/
$str="";
if ($c < 0x80) {
$str.=$c;
}
else if ($c < 0x800) {
$str.=chr(0xC0 | $c>>6);
$str.=chr(0x80 | $c & 0x3F);
}
else if ($c < 0x10000) {
$str.=chr(0xE0 | $c>>12);
$str.=chr(0x80 | $c>>6 & 0x3F);
$str.=chr(0x80 | $c & 0x3F);
}
else if ($c < 0x200000) {
$str.=chr(0xF0 | $c>>18);
$str.=chr(0x80 | $c>>12 & 0x3F);
$str.=chr(0x80 | $c>>6 & 0x3F);
$str.=chr(0x80 | $c & 0x3F);
}
return $str;
}
?>


--------------------------------------------
<?
Header ("Content-type: image/jpeg");
$im = imagecreate (800, 400);
$black = ImageColorAllocate ($im, 0, 0, 0);
$white = ImageColorAllocate ($im, 255, 255, 255);
include("gb2utf8.php");
$str=gb2utf8("aaa中過32434");
ImageTTFText ($im, 90, 10, 110, 300, $white, "/usr/share/fonts/default/TrueType/simsun.ttc",
$str);

ImageJPEG ($im);
ImageDestroy ($im);

?>

相關(guān)文章

最新評論

大名县| 黄浦区| 海门市| 米泉市| 西乌珠穆沁旗| 清丰县| 班戈县| 留坝县| 黔西| 吴忠市| 治多县| 五台县| 张家口市| 博野县| 图木舒克市| 山阴县| 玉树县| 阳新县| 顺平县| 含山县| 丰都县| 侯马市| 北宁市| 邵阳市| 绥德县| 林周县| 盐山县| 桐庐县| 抚州市| 佛山市| 丹江口市| 阿瓦提县| 交口县| 曲靖市| 延川县| 隆化县| 武安市| 通道| 大姚县| 达孜县| 常熟市|