有什么办法在gd库的图像里显示中文啊? 用iconv$str = iconv("GB2312","UTF-8","图片显示中文"); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 系统提示:Call to undefined function: iconv() 要一个函数。<?//Program writen by sadly www.phpx.comfunction 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));$utf8.=u2utf8(hexdec($codetable[hexdec(bin2hex($this))-0x8080]));}else{$gb=substr($gb,1,strlen($gb));$utf8.=u2utf8(substr($gb,0,1));}}$ret="";for($i=0;$i<strlen($utf8);$i+=3)$ret.=chr(substr($utf8,$i,3));return $ret;}function u2utf8($c){for($i=0;$i<count($c);$i++)$str="";if ($c < 0x80) {$str.=$c;}else if ($c < 0x800) {$str.=(0xC0 | $c>>6);$str.=(0x80 | $c & 0x3F);}else if ($c < 0x10000) {$str.=(0xE0 | $c>>12);$str.=(0x80 | $c>>6 & 0x3F);$str.=(0x80 | $c & 0x3F);}else if ($c < 0x200000) {$str.=(0xF0 | $c>>18);$str.=(0x80 | $c>>12 & 0x3F);$str.=(0x80 | $c>>6 & 0x3F);$str.=(0x80 | $c & 0x3F);}return $str;}?>还需要一个对照文本。去下一个。 <?phpHeader("Content-type: image/png"); $im = imagecreate(400,50);$bkg = ImageColorAllocate($im, 128,64,225); $clr = ImageColorAllocate($im, 255,255,255); $fnt = "c:\winnt\fonts\simsun.ttc";//定义字体文件$str = iconv("GB2312","UTF-8","大家好啊"); ImageTTFText($im, 20, 0, 230,40, $clr, $fnt, $str); $black = ImageColorAllocate($im, 0,0,0);$white = ImageColorAllocate($im, 255,255,255);imageline($im, 1, 1, 350, 25, $black);imagearc($im, 200, 15, 20, 20, 35, 190, $white);imagestring($im, 5, 4, 10, "Graph TEST!!", $white);ImagePNG($im); ImageDestroy($im); ?> 下面是我的代码,用了上面两位的两种方法,可是不成的。大家帮我看看是怎么回事啊?<?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));$utf8.=u2utf8(hexdec($codetable[hexdec(bin2hex($this))-0x8080]));}else{$gb=substr($gb,1,strlen($gb));$utf8.=u2utf8(substr($gb,0,1));}}$ret="";for($i=0;$i<strlen($utf8);$i+=3)$ret.=chr(substr($utf8,$i,3));return $ret;}function u2utf8($c){for($i=0;$i<count($c);$i++)$str="";if ($c < 0x80) {$str.=$c;}else if ($c < 0x800) {$str.=(0xC0 | $c>>6);$str.=(0x80 | $c & 0x3F);}else if ($c < 0x10000) {$str.=(0xE0 | $c>>12);$str.=(0x80 | $c>>6 & 0x3F);$str.=(0x80 | $c & 0x3F);}else if ($c < 0x200000) {$str.=(0xF0 | $c>>18);$str.=(0x80 | $c>>12 & 0x3F);$str.=(0x80 | $c>>6 & 0x3F);$str.=(0x80 | $c & 0x3F);}return $str;}Header("Content-type: image/png");$im = imagecreate(400,300);$bkg = ImageColorAllocate($im, 0,0,0);$clr = ImageColorAllocate($im, 255,255,255);$fnt = "c:/winnt/fonts/simhei.ttf";$str="";//$str = iconv("GB2312","UTF-8","安全指数"); //---系统提示无此函数$str1=gb2utf8("深圳市");$str.=$str1;imagestring($im, 5, 4, 10, $str, $clr);ImageTTFText($im, 20, 0, 10, 20, $clr, $fnt, $str);ImagePNG($im);ImageDestroy($im);?> "下面是我的代码,用了上面两位的两种方法,可是不成的。"==========================================================不成才怪!想用iconv();php.ini中:extension=php_iconv.dll;去掉注释. 我无法加载php_iconv.dll,同样的路径下,gd库,mssql库等其他都可以,为何? PHP版本?文件dlls/iconv.dll是否复制到系统目录下? 加载php_iconv.dll需要将php/dlls下的文件拷贝到系统目录下并需保证php版本在4.3.0以上,否则加载了也不支持gb2312使用对照表转换需下载gb2312.txt文件,230k。不过这张表也可以自行构造 flash在线剪切缩放批量修改程序 请教一个递归问题。 mysql数据更新问题。。。MYSQL板块冷清弄到这来 php怎样提取文本里面的需要的行到数组 带"/"的查询怎么办? 都什么方式可以解释php 【请赐教】PHP如何做群发邮件??(10万条以内) 裸体跪求-->播放流媒体文件的PHP实例代码! PHP关于发送邮件的问题 实在搞不定了, 关于win2000下用mail(); 谁做过在线html编辑器和数据库结合的,给个例子看看拉!谢谢啦!有的话给我一分,thx! 那位大虾给我介绍一下 PHP 呀?新手,谢谢!
<?//Program writen by sadly www.phpx.comfunction 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));
$utf8.=u2utf8(hexdec($codetable[hexdec(bin2hex($this))-0x8080]));
}
else
{
$gb=substr($gb,1,strlen($gb));
$utf8.=u2utf8(substr($gb,0,1));
}
}$ret="";
for($i=0;$i<strlen($utf8);$i+=3)
$ret.=chr(substr($utf8,$i,3));return $ret;
}function u2utf8($c)
{
for($i=0;$i<count($c);$i++)
$str="";
if ($c < 0x80) {
$str.=$c;
}
else if ($c < 0x800) {
$str.=(0xC0 | $c>>6);
$str.=(0x80 | $c & 0x3F);
}
else if ($c < 0x10000) {
$str.=(0xE0 | $c>>12);
$str.=(0x80 | $c>>6 & 0x3F);
$str.=(0x80 | $c & 0x3F);
}
else if ($c < 0x200000) {
$str.=(0xF0 | $c>>18);
$str.=(0x80 | $c>>12 & 0x3F);
$str.=(0x80 | $c>>6 & 0x3F);
$str.=(0x80 | $c & 0x3F);
}
return $str;
}
?>还需要一个对照文本。去下一个。
Header("Content-type: image/png"); $im = imagecreate(400,50);
$bkg = ImageColorAllocate($im, 128,64,225);
$clr = ImageColorAllocate($im, 255,255,255); $fnt = "c:\winnt\fonts\simsun.ttc";//定义字体文件
$str = iconv("GB2312","UTF-8","大家好啊");
ImageTTFText($im, 20, 0, 230,40, $clr, $fnt, $str); $black = ImageColorAllocate($im, 0,0,0);
$white = ImageColorAllocate($im, 255,255,255);
imageline($im, 1, 1, 350, 25, $black);
imagearc($im, 200, 15, 20, 20, 35, 190, $white);
imagestring($im, 5, 4, 10, "Graph TEST!!", $white);ImagePNG($im);
ImageDestroy($im);
?>
大家帮我看看是怎么回事啊?<?
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));
$utf8.=u2utf8(hexdec($codetable[hexdec(bin2hex($this))-0x8080]));
}
else
{
$gb=substr($gb,1,strlen($gb));
$utf8.=u2utf8(substr($gb,0,1));
}
}$ret="";
for($i=0;$i<strlen($utf8);$i+=3)
$ret.=chr(substr($utf8,$i,3));return $ret;
}function u2utf8($c)
{
for($i=0;$i<count($c);$i++)
$str="";
if ($c < 0x80) {
$str.=$c;
}
else if ($c < 0x800) {
$str.=(0xC0 | $c>>6);
$str.=(0x80 | $c & 0x3F);
}
else if ($c < 0x10000) {
$str.=(0xE0 | $c>>12);
$str.=(0x80 | $c>>6 & 0x3F);
$str.=(0x80 | $c & 0x3F);
}
else if ($c < 0x200000) {
$str.=(0xF0 | $c>>18);
$str.=(0x80 | $c>>12 & 0x3F);
$str.=(0x80 | $c>>6 & 0x3F);
$str.=(0x80 | $c & 0x3F);
}
return $str;
}Header("Content-type: image/png");
$im = imagecreate(400,300);
$bkg = ImageColorAllocate($im, 0,0,0);
$clr = ImageColorAllocate($im, 255,255,255);
$fnt = "c:/winnt/fonts/simhei.ttf";$str="";
//$str = iconv("GB2312","UTF-8","安全指数"); //---系统提示无此函数
$str1=gb2utf8("深圳市");$str.=$str1;imagestring($im, 5, 4, 10, $str, $clr);
ImageTTFText($im, 20, 0, 10, 20, $clr, $fnt, $str);
ImagePNG($im);
ImageDestroy($im);?>
==========================================================
不成才怪!想用iconv();
php.ini中:
extension=php_iconv.dll;去掉注释.
文件dlls/iconv.dll是否复制到系统目录下?
并需保证php版本在4.3.0以上,否则加载了也不支持gb2312使用对照表转换需下载gb2312.txt文件,230k。不过这张表也可以自行构造