GD does not work on file created in UTF-8

Asked

Viewed 90 times

1

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

But when I tried to create an image with GD, the image appears broken... Then when I switch to Western Europero (iso-8859-1). Works correctly.

How do I run this file created in UTF-8, so I can maintain the standard 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);
?>
  • 1

    I suspect it is due to GOOD. When using utf-8 make sure to remove the GOOD character (bit order mark)... To do this, using the text editor itself, set the charset to "UTF-8 Without BOM". This depends on the editor you use.. Some define it as "UTF-8 ANSI".

  • Interesting, because Dreanweaver when I put without BOM, he does nothing, still generating error... Then when I open Notepad++ it shows the UTF-8 normal, I believe it is a problem in Dreanweaver, because when I put no Good in Notepad++ works correctly...

  • @abcd If you can add as a response the problem resolution, then mark as accepted.

  • @Danielomine puts as answer your comment p/ we close this question

  • is done, Maison.

1 answer

1


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

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

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

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.