これは、前回登場したsmartyのoutputfilterプラグインで対応する。
こんなのを作って。
<?php
function smarty_outputfilter_convert_hankakukana ($output, &$smarty) {
return mb_convert_kana($output,'k', 'SJIS-WIN');
}
index.php(前回からフォルダ構成をモバイルとPCで分けたので、index_mobile.phpから改名した)
$config = new Zend_Config_Ini(dirname(__FILE__). '/../config/application.ini', SITE_ENVIRONMENT);
$view = new Hmr_View_Smarty($config);
$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view);
$viewRenderer->setViewBasePathSpec(dirname(__FILE__) . '/../modules/mobile/views/templates')
->setViewScriptPathSpec(':controller/:action.:suffix')
->setViewScriptPathNoControllerSpec(':action.:suffix')
->setViewSuffix('tpl');$view->loadFilter('output', 'convert_encoding');
$view->loadFilter('output', 'convert_hankakukana');←追加
といった具合でうまくいった。
きっと、モバイル側でカタカナの入力があったら全角に直す必要とかあるんだろうけど(PCとデータ共有している部分とか)、それはまた後日。
追記:上のコードじゃだめかも。
$view->loadFilter('output', 'convert_hankakukana');この順番じゃないと文字化けた。すません。
$view->loadFilter('output', 'convert_encoding');
コメントする