WordPressのサーバーを移転したらメニュー名を日本語にすると文字化けしたり、ファイルアップロードすると日本語部分が文字化けしたり。。
気になっていたのですが、ようやく原因がわかりました
移転前のPHPの設定
~~~
$ php -i | grep mbstring
/etc/php.d/mbstring.ini,
Zend Multibyte Support => provided by mbstring
mbstring
mbstring extension makes use of “streamable kanji code filter and converter”, which is distributed under the GNU Lesser General Public License version 2.1.
mbstring.detect_order => auto => auto
mbstring.encoding_translation => Off => Off
mbstring.func_overload => 0 => 0
mbstring.http_input => auto => auto
mbstring.http_output => UTF-8 => UTF-8
mbstring.http_output_conv_mimetypes => ^(text/|application/xhtml\+xml) => ^(text/|application/xhtml\+xml)
mbstring.internal_encoding => UTF-8 => UTF-8
mbstring.language => Japanese => Japanese
mbstring.strict_detection => Off => Off
mbstring.substitute_character => no value => no value
~~~
移転後のPHPの設定
~~~
$ php -i | grep mbstring
/etc/php.d/mbstring.ini,
Zend Multibyte Support => provided by mbstring
mbstring
mbstring extension makes use of “streamable kanji code filter and converter”, which is distributed under the GNU Lesser General Public License version 2.1.
mbstring.detect_order => auto => auto
mbstring.encoding_translation => On => On
mbstring.func_overload => 0 => 0
mbstring.http_input => auto => auto
mbstring.http_output => UTF-8 => UTF-8
mbstring.http_output_conv_mimetypes => ^(text/|application/xhtml\+xml) => ^(text/|application/xhtml\+xml)
mbstring.internal_encoding => UTF-8 => UTF-8
mbstring.language => Japanese => Japanese
mbstring.strict_detection => Off => Off
mbstring.substitute_character => no value => no value
~~~
mbstring.encoding_translation => On => On
これだけが違ったのでOFFにしたら問題解決(´∀`)
けどそもそもこの設定でいいのかな???
文字コードに起因する脆弱性を防ぐ「やや安全な」php.ini設定 – 徳丸浩の日記(2010-09-27)によるとこうすべきらしい
;; 出力バッファリングを無効にする (追記:文字エンコーディングの変換をしなければ、On でもいいです)
output_buffering = Off;; HTTPレスポンスの文字エンコーディングを設定
default_charset = UTF-8;; デフォルトの言語を日本語にする
mbstring.language = Japanese;; HTTP 入力変換を有効にする
mbstring.encoding_translation = On;; HTTP 入力エンコーディング変換を UTF-8 に設定(UTF-8→UTF-8の変換)
mbstring.http_input = UTF-8;; HTTPレスポンスは変換しない
mbstring.http_output = pass;; 内部エンコーディングを UTF-8 に設定
mbstring.internal_encoding = UTF-8;; 無効な文字は「?」に
mbstring.substitute_character = “?”
記事が古いけどPHP5.4最新でもこの設定が必要なのかな?とは思いつつ、やってて損はないだろうしこちらで文字化けしないことは確認できたのでこれで様子を見ようと思います
~~~
$ php -i | grep mbstring
/etc/php.d/mbstring.ini,
Zend Multibyte Support => provided by mbstring
mbstring
mbstring extension makes use of “streamable kanji code filter and converter”, which is distributed under the GNU Lesser General Public License version 2.1.
mbstring.detect_order => auto => auto
mbstring.encoding_translation => On => On
mbstring.func_overload => 0 => 0
mbstring.http_input => UTF-8 => UTF-8
mbstring.http_output => pass => pass
mbstring.http_output_conv_mimetypes => ^(text/|application/xhtml\+xml) => ^(text/|application/xhtml\+xml)
mbstring.internal_encoding => UTF-8 => UTF-8
mbstring.language => Japanese => Japanese
mbstring.strict_detection => Off => Off
mbstring.substitute_character => ? => ?
~~~
コメント