PHP generates Chinese Verification Code garbled Problem Solution
// The Chinese character to be processed, which is converted from the UTF8 Chinese character to the html Entity before being used.
// Sample code:
// Ini_set ('jis-mapped Japanese Font Support ', false );
$ Pic = imagecreate (250,30 );
$ Black = imagecolorallocate ($ pic, 0, 0 );
$ White = imagecolorallocate ($ pic, 255,255,255 );
$ Font = "C: // WINDOWS // Fonts // simhei. ttf ";
$ Str = 'people's Republic of China ';
$ Str = mb_convert_encoding ($ str, "html-entities", "UTF-8"); // result: & #21738; & #19968; & #38431; & #20248; & #20808; & #24320; & #29699;
Imagettftext ($ pic, 10, 0, 10, 20, $ white, $ font, $ str );
Header ("Content-type: image/jpeg ");
$ Filename = './photo.jpg ';
$ Im = imagecreatefromjpeg ($ filename );
Imagecopymerge ($ im, $ pic, 50 );
Imagejpeg ($ im );
// PChart sample code:
/*
Example14: A smooth flat pie graph
*/1 2