title: How to set charset to UTF-8 in a Zend application?
body: <p>I am developping a Zend application. The data in my database is encoded in "utf8_unicode_ci".
  I declared in my application.ini :</p>
  
  <pre><code>resources.view.encoding = "UTF-8"
  </code></pre>
  
  <p>but whenever I try to retrieve a String containing special characters like </p>
  
  <p>{'é', 'à', 'è',...} in the db, the string doesn't display unless I use the function : <code>utf8_decode()</code></p>
  
  <p>So I tried to set the charset to UTF-8 in :</p>
  
  <p>Bootstrap :</p>
  
  <pre><code>protected function _initDoctype() {
        $this-&gt;bootstrap('view');
        $view = $this-&gt;getResource('view');
        $view-&gt;doctype('XHTML_STRICT');
        $view-&gt;setEncoding('UTF-8');
   }
  
   protected function _initFrontControllerOutput() {
  
      $this-&gt;bootstrap('FrontController');
      $frontController = $this-&gt;getResource('FrontController');
  
      $response = new Zend_Controller_Response_Http;
      $response-&gt;setHeader('Content-Type', 'text/html; charset=UTF-8', true);
      $frontController-&gt;setResponse($response);
  
      $frontController-&gt;setParam('useDefaultControllerAlways', false);
  
      return $frontController;
  }
  </code></pre>
  
  <p>Layout :</p>
  
  <pre><code>$this-&gt;headMeta()-&gt;appendHttpEquiv('Content-Type', 'text/html;charset=utf8');
  echo $this-&gt;headMeta();
  </code></pre>
  
  <p>application.ini :</p>
  
  <pre><code>resources.view.encoding = "UTF-8"
  resources.db.params.charset = "utf8"
  </code></pre>
  
  <p>EDIT : Now I can display special chars in a page, but when I retrieve elements from the database, special chars are not displayed.</p>
  
  <ul>
  <li>an escaped string returns <code>null</code> (<code>$this-&gt;escape($string)</code>)</li>
  <li><code>echo $string</code> substitutes special chars with <code>?</code></li>
  </ul>
  
  <p>so I still have to use <code>utf8_decode()</code> to display them. Any suggestion ?</p>
  
  <p>thanks for your help !!</p>