Per ottenere un UTF-8 valido in php si deve considerare sorgente (html,php,javascript,text),header(html,php,javasci pt,text) e nonchè le funzioni php che operano con le stringhe.. image.php
Codice PHP:
<?php
// Set the content-type
header('Content-Type: image/png');
// Create the image
$im = imagecreatetruecolor(400, 30);
// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);
// The text to draw
$text = 'Testing...1°';
// Replace path by your own font path
$font = './Pacifico.ttf';
// Add some shadow to the text
// html_entity_decode() for < php 5.6
imagettftext($im, 20, 0, 11, 21, $grey, $font, html_entity_decode($text, ENT_COMPAT, 'UTF-8').html_entity_decode($text));
// Add the text
// html_entity_decode() for < php 5.6
imagettftext($im, 20, 0, 10, 20, $black, $font, html_entity_decode($text, ENT_COMPAT, 'UTF-8').html_entity_decode($text));
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>
script.php
Codice PHP:
<?php
header('Content-type: text/html; charset=utf-8');
$word = 'ciao 1°';
$text =
html_entity_decode($word, ENT_COMPAT, 'UTF-8');
$text .= html_entity_decode($word);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
</head>
<body>
<p>Ecco la mia prima pagina in html destinata al web <?php print_r($text); ?></p>
<img src="image.php">
</body>
</html>
http://www.fonts2u.com/pacifico-regular.font
Nel caso dei font (tipo di carattere) si deve considerare anche il sistema operativo in uso... cmq. a me il simbolo grado decodificato da un'entita html si vede (ISO-8859-1 o UTF-8).
Tre esempi di esadecimali per il simbolo grado.
Codice:
unicode 2.0 00B0
utf-8 C2B0
iso-8859-1 B0