fpdf € transform into ? with UTF-8

You try to write a € character on your pdf doc but it is transformed into a “?”.
You can replace it by the chr(128) sign.

$this->MultiCell(170, $this->hh, $price." ".chr(128), 0, 'L', false);

When the sign is inside a string, you can use this

$contenu = str_replace('€', chr(128), $contenu);
$this->MultiCell(170, $this->hh, $contenu, 0, 'L', false);

But you have special characters too, you need to encode string into UTF-8

$contenu = str_replace('€', chr(128), $contenu);
$this->MultiCell(170, $this->hh, utf8_decode($contenu), 0, 'L', false);

This works well for “é” or “ç” but not for “€”.
The ultimate solution is :

$contenu = str_replace('€', utf8_encode(chr(128)), $contenu);
$this->MultiCell(170, $this->hh, utf8_decode($contenu), 0, 'L', false);

Leave a Reply