[Resolvido] encoding não está sendo setado

Zend_Controller, Zend_Controller_Action, Zend_Controller_Dispatcher, Zend_Controller_Plugin, Zend_Controller_RewriteRouter, Zend_View, Zend_Http_Request, Zend_Http_Response

Moderador: chackal_sjc

[Resolvido] encoding não está sendo setado

Mensagempor andrecf » Seg Out 19, 2009 11:13 am

Bom dia,

Estou tentando setar o encoding para as views, contudo não está sendo setado. Todas as páginas estão usando UTF-8, no application.ini tenho a seguinte linha:

Código: Selecionar tudo
resources.view.encoding = "UTF-8"


E meu bootstrap está assim:
Código: Selecionar tudo
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
   public function _initAutoload()
   {
      $autoloader = new Zend_Application_Module_Autoloader(
         array(
            'namespace' => '',
            'basePath' => APPLICATION_PATH
         )
      );
      
      return $autoloader;
   }
   
   public function _initLayouts()
   {
      Zend_Layout::startMvc();
      $this->getPluginResource('frontController')
         ->getFrontController()
         ->registerPlugin(new Plugin_ModuleLayout());
   }
   
   protected function _initDoctype()
  {
       $this->bootstrap('view');
      $view = $this->getResource('view');
      $view->doctype('XHTML1_STRICT');
  }
   
   public function _initDbProfile()
   {
      // não devemos nunca usar isto em produção,
      // por essa razão temos esta condição (o melhor é ficar somente em
      // desenvolvimento)
      if ($this->getEnvironment() == 'development')
      {
         $profiler = new Zend_Db_Profiler_Firebug('All DB Queries');
         
         $db = $this->getPluginResource('db');
         $db = $db->getDbAdapter();
         $profiler->setEnabled(true);
         $db->setProfiler($profiler);
      }
   }
   
}


Além disso, tenho o seguinte template do default (layout.phtml):

Código: Selecionar tudo
<?php echo $this->docType(); ?>
<html>
<head>
   <?php echo $this->headTitle(); ?>
   <?php echo $this->headLink(); ?>
   <?php echo $this->headStyle(); ?>
   <?php echo $this->headScript(); ?>
   <?php echo $this->headLink()->appendStylesheet('/css/global.css') ?>
</head>
<body>
   <?php echo $this->layout()->content ?>
</body>
</html>


O que pode estar faltando para que a view sete o encoding como UTF-8?

Desde já agradeço,
André.
andrecf
Leitor
 
Mensagens: 4
Data de registro: Ter Set 08, 2009 8:35 pm

Re: encoding não está sendo setado

Mensagempor vdsantos » Sex Out 23, 2009 10:25 am

De uam olhada no bootstrap da URL abaixo, talvez possa lhe ajudar a fazer alguma adaptação:

http://raiyaraj.wordpress.com/2008/08/0 ... bootstrap/

Valew
vdsantos
Participante
 
Mensagens: 43
Data de registro: Seg Jun 08, 2009 2:38 pm
Localização: Guarulhos - SP

Re: encoding não está sendo setado

Mensagempor TulioBraga » Sex Out 23, 2009 4:52 pm

Está faltando chamar o view helper placeholder que define o encoding da sua página:

Código: Selecionar tudo
echo $this->headMeta()->appendHttpEquiv('Content-Type','text/html; charset=UTF-8')
                 ->appendHttpEquiv('Content-Language', 'pt-BR');


Dê uma olhada nestes links para um maior entendimento e aprofundamento neste tipo de helper.

http://devzone.zend.com/article/3412
http://framework.zend.com/manual/en/zend.view.helpers.html#zend.view.helpers.initial.placeholder.implementations
Avatar de usuário
TulioBraga
Participante
 
Mensagens: 51
Data de registro: Sex Mar 06, 2009 12:00 am
Localização: Belo Horizonte

Re: encoding não está sendo setado

Mensagempor andrecf » Qua Out 28, 2009 4:05 pm

É isso mesmo, obrigado. Eu acabei confundindo dois conceitos, agora consegui fazer funcionar.
Obrigado.
andrecf
Leitor
 
Mensagens: 4
Data de registro: Ter Set 08, 2009 8:35 pm


Retornar para Model-View-Controller (MVC)

Quem está online

Usuários vendo este fórum: Nenhum usuário registrado online e 1 visitante