どうも、mb_detect_encodingが動作しないようで、サンプルで用意したSJISやEUCで記載された文章の文字コードを
認識してくれません。
何度やってもmb_detect_encodingの返り値はNULLです。
サンプルで用意した文章は、76KB程のものを用意しました。
/etc/php.ini.default は色々いじったのですが、上手くいかないので戻しました。
同じフォルダに以下の.htaccessを入れてみました。
しかし結果は同じでした。
ーー
php_value default_charset UTF-8
php_value mbstring.language Japanese
php_flag mbstring.encoding_translation ON
php_value mbstring.detect_order UTF-8,EUC-JP,SJIS,JIS,ASCII
php_value mbstring.internal_encoding UTF-8
php_value mbstring.http_input auto
php_value mbstring.http_output pass
php_value mbstring.substitute_character none
php_value output_handler none
ーー
Web共有の再起動は実施済みです。
phpinfo()の値はコメントに記載します。
どうすれば、MacOSX10.5.6におけるPHPでもmb_detect_encodingが正常に動くようになるのか
よろしければ教えてください。お願いします。
phpinfo() で mbstring.detect_order に値が設定されていないのが原因だと思います。
まず、下記の実行結果をお知らせください。
print_r(mb_detect_order());
もし適切な配列の値が表示されないようでしたら、下記のようにしてください。
mb_detect_order('UTF-8,EUC-JP,SJIS,JIS,ASCII');
Multibyte Support enabled
Multibyte string engine libmbfl
Multibyte (japanese) regex support enabled
Multibyte regex (oniguruma) version 4.4.4
Multibyte regex (oniguruma) backtrack check On
mbstring extension makes use of "streamable kanji code filter and converter", which is distributed under the GNU Lesser General Public License version 2.1.
Directive Local Value Master Value
mbstring.detect_order no value no value
mbstring.encoding_translation Off Off
mbstring.func_overload 0 0
mbstring.http_input pass pass
mbstring.http_output pass pass
mbstring.internal_encoding no value no value
mbstring.language neutral neutral
mbstring.strict_detection Off Off
mbstring.substitute_character no value no value
よろしくお願いします。
$InputEncoding = mb_detect_encoding(<文字列>, "auto");
の<文字列>が、UTF-8の場合のみ正常に $InputEncoding の値が
UTF-8を返す事を確認しています。
しかし EUCや SJIS等の場合にも対応できるようにしたいので
対処法ご存知の方はよろしくお願いします。
> しかし結果は同じでした。
ここで指している、「同じフォルダ」とは、mb_detect_encodingなどを記載している
テストプログラムと同じフォルダの事であり、MaxOSXのapacheが公開している一般の領域内です。
よろしくお願いします。