またEthnaを触ってます。
今回はEthna2.3.1 + Smarty2.6.18で。
いろいろな事情でコンテンツの文字コードはShift_JISだ。
で、予想通り、コンテンツ表示させると、文字化けする。
ブラウザの仕様か、Ethnaの仕様か、Smartyの仕様かわからんのだが、
Content-Type: text/html; charset=UTF-8
HTTPレスポンスヘッダにこんなもんを吐きやがる。
EthnaにもSmartyにもヘッダとして、UTF-8と明示された部分がない。
もーよく分からなくなってきたし、まんどくせーので力で解決。
Ethna_ViewClass派生クラスにて、
// {{{ preforward
/**
* 画面表示前処理
*
* テンプレートに設定する値でコンテキストに依存しないものは
* ここで設定する(例:セレクトボックス等)
*
* @access public
*/
function preforward()
{
header('Content-Type: text/html; charset=Shift_JIS');
}
// }}}
やったなおったwww 力こそ正義wwwwww つーか、いいのかこれでwwwwwwwww
気になるHTTPレスポンスヘッダは、こうだ。
修正前
$ GET -e -d http://192.168.0.***/index.php Connection: close Date: Fri, 01 Jun 2007 08:36:23 GMT Server: Apache/2.0.52 (CentOS) Content-Length: 727 Content-Type: text/html; charset=UTF-8 Content-Type: text/html; charset=Shift_JIS Client-Date: Fri, 01 Jun 2007 08:36:23 GMT Client-Peer: 192.168.0.252:80 Client-Response-Num: 1 Link: <css/ethna.css>; /="/"; rel="stylesheet"; type="text/css" X-Powered-By: PHP/5.2.2
修正後
$ GET -e -d http://192.168.0.***/index.php Connection: close Date: Fri, 01 Jun 2007 08:36:23 GMT Server: Apache/2.0.52 (CentOS) Content-Length: 727 Content-Type: text/html; charset=Shift_JIS Content-Type: text/html; charset=Shift_JIS Client-Date: Fri, 01 Jun 2007 08:36:23 GMT Client-Peer: 192.168.0.252:80 Client-Response-Num: 1 Link: <css/ethna.css>; /="/"; rel="stylesheet"; type="text/css" X-Powered-By: PHP/5.2.2
なんで、Content-Typeが2回も渡されてるんだゴルァ
こちらは、Live HTTP Headerでの出力。
修正前
http://192.168.0.***/index.php GET /index.php HTTP/1.1 Host: 192.168.0.252 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.8.0.12) Gecko/20070508 Firefox/1.5.0.12 Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 Accept-Language: ja,en-us;q=0.7,en;q=0.3 Accept-Encoding: gzip,deflate Accept-Charset: Shift_JIS,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Cache-Control: max-age=0 HTTP/1.x 200 OK Date: Fri, 01 Jun 2007 08:48:43 GMT Server: Apache/2.0.52 (CentOS) X-Powered-By: PHP/5.2.2 Content-Length: 727 Connection: close Content-Type: text/html; charset=UTF-8
修正後
http://192.168.0.***/index.php GET /index.php HTTP/1.1 Host: 192.168.0.252 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.8.0.12) Gecko/20070508 Firefox/1.5.0.12 Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 Accept-Language: ja,en-us;q=0.7,en;q=0.3 Accept-Encoding: gzip,deflate Accept-Charset: Shift_JIS,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Cache-Control: max-age=0 HTTP/1.x 200 OK Date: Fri, 01 Jun 2007 08:47:42 GMT Server: Apache/2.0.52 (CentOS) X-Powered-By: PHP/5.2.2 Content-Length: 727 Connection: close Content-Type: text/html; charset=Shift_JIS
うーん、まあいいのか。とりあえず。。。