note 30058 deleted from ref.image by tularis

From: Date: Sun, 29 Jun 2008 21:12:59 +0000
Subject: note 30058 deleted from ref.image by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-140981@lists.php.net to get a copy of this message
Note Submitter: cysoft at php dot net ---- How to using GD out put chinese Characters (BIG 5 or GB2312). the following code shows you how to using gd display chinese Characters. there is a funcation called by ImageTTFText. since gd dose not support GB2312/big5 but unicode.if you can convert Characters to unicode which you want display then every thing will be done! your 's yan <?php function gb23122uni($text) { $rtext=""; $max=strlen($text); for($i=0;$i<$max;$i++){ $h=ord($text[$i]); if($h>=160 && $i<$max-1){ $rtext.="&#".base_convert(bin2hex(iconv("gb2312","ucs-2", substr($text,$i,2))),16,10).";"; $i++; }else{ $rtext.=$text[$i]; } } return $rtext; } Header("Content-type: image/gif"); $im = imagecreate(400,50); $black = ImageColorAllocate($im, 0,255,0); $white = ImageColorAllocate($im, 255,0,255); ImageTTFText($im, 20, 0, 30, 30, $white, "c:\php\STCAIYUN.ttf",gb23122uni(" ÄãºÃ")."test"); Imagejpeg($im); ImageDestroy($im); ?>

« previous php.notes (#140981) next »