I am developing a Zend application. The data in my database is encoded in "utf8_unicode_ci". I stated in my application.ini application:
resources.view.encoding = "UTF-8"
but whenever I try to get a string containing special characters like
{'รฉ', 'ร ', 'รจ', ...} in db, the line does not appear if I do not use this function: utf8_decode()
So, I tried to set the encoding in UTF-8 to:
Loading tray:
protected function _initDoctype() { $this->bootstrap('view'); $view = $this->getResource('view'); $view->doctype('XHTML_STRICT'); $view->setEncoding('UTF-8'); } protected function _initFrontControllerOutput() { $this->bootstrap('FrontController'); $frontController = $this->getResource('FrontController'); $response = new Zend_Controller_Response_Http; $response->setHeader('Content-Type', 'text/html; charset=UTF-8', true); $frontController->setResponse($response); $frontController->setParam('useDefaultControllerAlways', false); return $frontController; }
Layout:
$this->headMeta()->appendHttpEquiv('Content-Type', 'text/html;charset=utf8'); echo $this->headMeta();
application.ini:
resources.view.encoding = "UTF-8" resources.db.params.charset = "utf8"
EDIT: Now I can display special characters on the page, but when I retrieve items from the database, special characters are not displayed.
- escaped string returns
null ( $this->escape($string) ) echo $string replace special characters with ?
so I have to use utf8_decode() to display them. Any suggestion?
thanks for your help!
source share