This project is read-only.

Euro sign

Dec 8, 2010 at 3:22 PM


Does someone know how to insert a euro sign in PHPWord?
The dollar sign works fine, but the euro sign not (€).

I've been looking for an answer for hours, but I couldn't find one.

Thank you!

Dec 9, 2010 at 1:16 AM

Maybe the ascii will work: chr(8364)

The problem is that this won't work if your font does not have a euro symbol, so use newer fonts in your docx.

More information about ascii here:

Oct 12, 2011 at 11:22 PM

I have a solution but we have to change the source code of PHPWord.
The problem is the use of utf8_encode (for example in Section.php file).

public function addText($text, $styleFont = null, $styleParagraph = null) {
    $givenText = utf8_encode($text);
    $text = new PHPWord_Section_Text($givenText, $styleFont, $styleParagraph);
    $this->_elementCollection[] = $text;
    return $text;

utf8_encode() take an ISO-8859-1 encoded string as parameter. But euro sign exists in ISO-8859-15 but not in ISO-8859-1. 

If we send a ISO-8859-15, we have the ¤ sign by using utf8_encode() and not €.
The solution is to remove the utf8_encode() and use a utf8 encoded string as parameter of addText().

Nov 17, 2011 at 12:55 PM


Could you give an example how to fix it? I removed the utf8_encode in Section.php. But how further??


Jun 5, 2012 at 12:07 PM

I've found another solution modifying the source code (adding a code line that implements the php function 'str_replace').

Go to the function 'addText' in the file that corresponds.

In my case (cause I'm creating a table), I added the code line in this function in: PHPWord\Section\Table\Cell.php

public function addText ($text, $styleFont = null, $styleParagraph = null)
        $text = utf8_encode($text);
        $text = str_replace(array("€","€"),"€",$text); // The line added
        $text = new PHPWord_Section_Text($text, $styleFont, $styleParagraph);
        $this->_elementCollection [] = $text;
        return $text;

Notes: '€' is if the source is HTML
          '€'  is if the source is utf8_unicode

          Depending on where it is used, the 'addText' function can be found in : Cell.php , Footer.php , Header.php , Section.php , TextRun.php .


Jan 7, 2014 at 7:30 AM
Got the same problem and tried the code of Eclectic.

It didn't worked for me and so i modified it a little bit ...

I added this line:
 $text = str_replace("E_U_R_O", "€" ,$text); 
On the same position and in my Text i use now E_U_R_O when i want to create a € sign in my word document.

Poor i know, but it works and maybe its a solution for someone else.
Mar 20, 2014 at 6:21 AM
The latest version of PHPWord can add utf8 character.