|
|
把GB码转换到UTF8,PHP中TTF支持UTF8编码的非ASCII字符输出,可以实现中文与ASCII混合输出图象,这样在我们操作图象函数时可以更方便.
要实现这个功能需要两个文件:
文件一:GB->UTF8转码表文件
文件二:GB->UTF8转换类文件 ( 这连个文件随后附上)
有了这两个文件就可以用如下代码来实现在图像中输出中文了。
代码在 http://tech.xianfeng.net/old/img.php 完全通过
[code:1:c4de57135f]<?php
session_start();
if (isset($vt)) {$vt++;}
else {$vt=1;}
session_register("vt");
Header("Content-type: image/png");
$ip=$REMOTE_ADDR;
$im = imagecreate(400,300);
$black = ImageColorAllocate($im, 0,0,0);
$white = ImageColorAllocate($im, 184,44,6);
include("gb2utf8.class");
//ImageTTFText(im,size,angle,x,y,color,font,text);
$obj=new gb2utf8("您好,您的IP为".$REMOTE_ADDR);
ImageTTFText($im, 20, 0, 5, 50, $white, "/home/www/tech/old/STXINGKA.TTF", $obj->str);
$obj=new gb2utf8("\n\n当前是您第".$vt."次访问本页面");
ImageTTFText($im, 20, 0, 5, 50, $white, "/path/to/STXINGKA.TTF", $obj->str);
ImagePNG($im);
ImageDestroy($im);
?>[/code:1:c4de57135f]
| HonestQiao 回复于:2003-06-07 16:25:49
| gb2312.txt
http://tech.xianfeng.net/old/gb2312.txt
| | HonestQiao 回复于:2003-06-07 16:26:12
| gb2utf8.class
http://tech.xianfeng.net/old/gb2utf8.class
| | macleo 回复于:2003-06-07 17:38:04
| 还是要发成代码模式的!
你发的又的成了笑脸的………………你自己看吧!
如果,我弄下来,还得改啊!谢谢,大侠!
| | HonestQiao 回复于:2003-06-07 17:52:15
| 现在好了,我把文件连接直接给出来了哦
| | macleo 回复于:2003-06-07 18:28:49
| 谢谢啦!不过,大侠有没有使用过libiconv进行内码转换.
| | macleo 回复于:2003-06-07 18:32:31
| 有虾哥介绍,这样会有效的多!(有效率!)
| | macleo 回复于:2003-06-08 00:16:29
| 给的源代码把显示ip来源的给删了! :cry: :cry:
| | macleo 回复于:2003-06-08 01:26:07
| 把你追捕的数据wry.dll给我用用!
| | macleo 回复于:2003-06-08 01:29:50
| 好!我找了个wry.dll!
[url]http://club.263xp.com/macleo/ipshow.php[/url]
| | macleo 回复于:2003-06-08 01:32:21
| 当然,谢谢大侠您提供的gb2utf8.class!
谢谢你!我在研究一下!
| | macleo 回复于:2003-06-08 01:35:53
| [img:59bb618d14]http://club.263xp.com/macleo/ipshow.php[/img:59bb618d14]
| | qiuzf 回复于:2003-12-16 17:10:09
| 可以直接用php中的函数iconv 来做, 如下是我的代码, 在w2k + apache +php 可以通过.
Header ("Content-type: image/jpeg");
$im = imagecreate (760,420);
$black = ImageColorAllocate ($im, 0, 0, 0);
$white = ImageColorAllocate ($im, 255, 255, 255);
$str=iconv("GB2312","UTF-8","qiuzf 裘泽锋 q_zefeng@21cn.com");
ImageTTFText ($im, 30, 0, 0, 60, $white, "c:\\winnt\\fonts\\simsun.ttc", $str);
ImageJPEG ($im);
ImageDestroy ($im);
| | Anna.yuan 回复于:2004-05-10 23:04:45
| :cry: 無法正確的顯示中文,請各位高手指點
環境:windows XP(繁體)+ php4.3.6+apache2.0.49
已經加載GD及iconv Library(gd2.0.22+iconv1.8)
<? Header ("Content-type: image/jpeg");
$im = imagecreate (760,420);
$black = ImageColorAllocate ($im, 0, 0, 0);
$white = ImageColorAllocate ($im, 255, 255, 255);
//已經相應的修改成Big5
$str=iconv("big5","UTF-8","qiuzf 中文顯示");
ImageTTFText ($im, 30, 0, 0, 60, $white, "c:\\WINDOWS\\fonts\\mingliu.ttc", $str);
ImageJPEG ($im);
ImageDestroy ($im);?>
| |
|