●参考サイト

http://www.ninnin.net/blog/archives/000356.html

●共通系のところに下記関数追加

//--------------------------------
// Smarty SJIS対応用関数1
//--------------------------------
function convert_encoding_to_eucjp($template_source) {
   if (function_exists("mb_convert_encoding")) {
       //文字コードを変換する
       return mb_convert_encoding($template_source, "EUC-JP", "SJIS");
   }
   return $template_source;
}

//--------------------------------
// Smarty SJIS対応用関数2
//--------------------------------
function convert_encoding_to_sjis($template_source) {
   if (function_exists("mb_convert_encoding")) {
       //文字コードを変換する
       return mb_convert_encoding($template_source, "SJIS", "EUC-JP");
   }
   return $template_source;
}

●smartyオブジェクトをnewしたあとに以下を追加

$smarty->register_prefilter("convert_encoding_to_eucjp");
$smarty->register_postfilter("convert_encoding_to_sjis");
最終更新:2009年05月18日 16:13