title: Missing chars in JpGraph
body: <p>I have a web site that runs on Windows and uses <code>cp1252</code> (aka <code>Win-1252</code>) so it can display Spanish characters. The app generates some plots with <strong>JpGraph 2.3</strong>. These plots use the Tahoma Open Type font family to display text labels. Strings are provided in ANSI (i.e., cp1252) and font files support cp1252 (actually, the *.ttf files were copied from the system's font folder).</p>
  
  <p>It's been working fine in several setups from PHP/5.2.6 to PHP/5.3.0. Problems started when I ran the app under <strong>PHP/5.3.1</strong>: all non-ASCII are replaced by the hollow rectangle that represents missing or unknown chars.</p>
  
  <p>JpGraph's documentation is not very precise about how it expects international chars. Apparently, text is handled internally by the imagettftext() function, which expects UTF-8. However, encoding everything as UTF-8 breaks the app in all the systems. Where ANSI used to work fine, I get wrong characters (<strong>Ê</strong> instead of <strong>Ú</strong>). Where I got missing chars, now I get a PHP error:</p>
  
  <blockquote>
    <p>Warning: imagettftext(): any2eucjp():
    something happen</p>
  </blockquote>
  
  <p>Do you have any clue about what changed in GD2 from PHP/5.3.0 to 5.3.1 that could be affecting the rendering on non-ASCII chars? How am I expected to feed JpGraph with strings in the Win-1252 charset?</p>
  
  <h2>Update</h2>
  
  <p>Definitively, the issue is not related to JpGraph. I can reproduce the issue with a simple call to imagettftext():</p>
  
  <pre><code>&lt;?php
  
  $im = imagecreatetruecolor(400, 30);
  
  $white = imagecolorallocate($im, 255, 255, 255);
  $black = imagecolorallocate($im, 0, 0, 0);
  imagefilledrectangle($im, 0, 0, 399, 29, $white);
  
  //$text = 'áéíóú ÁÉÍÓÚ'; # ANSI
  $text = utf8_encode('áéíóú ÁÉÍÓÚ'); # UTF8
  
  $font = '/path/to/tahomabd.ttf';
  imagettftext($im, 15, 0, 10, 25, $black, $font, $text);
  
  header('Content-Type: image/png');
  imagepng($im);
  imagedestroy($im);
  
  ?&gt;
  </code></pre>
  
  <p>In PHP/5.3.0, both ANSI and UTF-8 render the right text. In PHP/5.3.1, ANSI renders wrong characters and UTF-8 triggers the <code>any2eucjp(): something happen</code> internal error. I'd dare say I've hit a bug...</p>