#46293 [Opn]: imagettftext() function doesn't handle UTF-8 encoded strings

From: Date: Tue, 14 Oct 2008 16:19:58 +0000
Subject: #46293 [Opn]: imagettftext() function doesn't handle UTF-8 encoded strings
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-129691@lists.php.net to get a copy of this message
ID: 46293 User updated by: php at ibeni dot net Reported By: php at ibeni dot net Status: Open Bug Type: GD related Operating System: FreeBSD c1 6.3-RELEASE PHP Version: 5.2.6 New Comment: I see that bug submission forum has "helpfully" encoded the Japanese text in my code into HTML entities ('日本語'). In my original code, the text is encoded directly in UTF-8 _not_ HTML entities. Previous Comments: ------------------------------------------------------------------------ [2008-10-14 16:16:21] php at ibeni dot net Description: ------------ Passing UTF-8 encoded text with Japanese characters to imagettftext() produces incorrect output. Works correctly on my Ubuntu 7.10 machine, but broken on FreeBSD 6.3, web server. Reproduce code: --------------- mb_language('uni'); mb_internal_encoding('UTF-8'); header('Content-type: image/gif'); $text = '日本語'; //Japanese text $font = './Cyberbit.ttf'; // Create the image $im = imagecreatetruecolor(160, 160); $white = imagecolorallocate($im, 255, 255, 255); $black = imagecolorallocate($im, 0, 0, 0); // Create some colors imagefilledrectangle($im, 0, 0, 159, 159, $white); // Add the text imagettftext($im, 12, 0, 20, 20, $black, $font, $text); imagegif($im); imagedestroy($im); Expected result: ---------------- Copy of correct image from my local machine: http://www.ibeni.net/flashcards/imagetest.php.gif Copy of phpinfo() from my local machine: http://www.ibeni.net/flashcards/phpinfo.php.html Actual result: -------------- Broken Image on web server: http://www.ibeni.net/flashcards/imagetest.php Copy of phpinfo() from my webhost server: http://example5.nfshost.com/phpinfo ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=46293&edit=1

« previous php.bugs (#129691) next »