GD does not work on file created in UTF-8

1

I would like to know how to proceed in a situation. Where by default I create all the site files with UTF-8 encoding.

But when I tried to create an image with GD, the image appears broken ... Hence when I change to Western Europero (iso-8859-1). It works properly.

How do I work with this file created in UTF-8, so I can keep the pattern of creating the files?

<?php
header("Content-type: image/png");
$im = @imagecreate(200, 800)
    or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 0, 0, 0);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 10, 5, 5,  "A Simple é você Text String", $text_color);
imagepng($im);
imagedestroy($im);
?>
    
asked by anonymous 20.03.2015 / 15:23

1 answer

1

When using UTF-8 make sure to remove the BOM (bit order mark) character.

To do this, using the text editor itself, set the charset to "UTF-8 Without BOM".

This feature depends on the editor you are using. Some define it as "UTF-8 ANSI".

Note that this answer is based on an assumption. Others may have a similar problem whose cause is different from the proposed solution.

    
17.04.2015 / 20:40