fetus Diary
2006/02/28(火) - 携帯版らしきもの
2 分で SJIS になったよ…。(内部的には UTF-8 で動いてるけど)
Smarty の plugins に outputfilter.utf2sjis.php というファイルを作成。
<?php
function smarty_outputfilter_utf2sjis($source, &$smarty)
{
return mb_convert_encoding($source, 'SJIS', 'UTF-8');
}
?>
こうして、View (の自作基底)クラスの render 関数に
if($this->isMobileMode()) {
$this->getEngine()->autoload_filters = array('output' => array('utf2sjis'));
if(! headers_sent()) {
header('Content-Type: text/html; charset=Shift_JIS');
}
}
こんな感じで。
関数名の "UTF-8" が utf に省略されているのは気にしない方向で。UTF-7 や UTF-16, UTF-32 なんて使わない (UTF-1, 5 は論外)し、utf82sjis とかわけがわかんないし。Utf8ToSjis や convert_utf8_to_shiftjis にしなさいなんていうツッコミはナシということにしておいてください。
06/02/28 17:5606/03/01 16:53
コメント
コメントはありません。