Do You PHP はてブロ

Do You PHPはてなからはてブロに移動しました

PHP5.2.0でmultipart/form-dataを使用すると文字化け

すみません。以下の情報は意味がありません。次のエントリを参照してください!

なんか、php-usersにメールを送れないのでこっちに書いときます。


以下1〜3まで変更をphp.iniへ加え、そのたびにApacheを再起動して確認しましたが同じく文字化けしました。Apache2.2.3 + PHP5.2.0です。
1.mbstring.strict_detection = On を追加
2.mbstring.http_input = SJIS に変更
3.mbstring.detect_order = SJIS に変更
いずれにしてもformタグから enctype="multipart/form-data" を削除すると文字化けはしません。なので文字コードの誤検知は考えにくいように思います。

こちらでも試してみました。とりあえず、

output_buffering = Off      <=========
output_handler = none       <=========
magic_quotes_gpc = Off
default_charset = Shift_JIS
mbstring.language = Japanese
mbstring.internal_encoding = EUC-JP
mbstring.http_input = auto
mbstring.http_output = SJIS
mbstring.encoding_translation = Off       <=========
mbstring.detect_order = auto
mbstring.substitute_character = none;
mbstring.func_overload = 0
mbstring.strict_encoding = On

とすると、期待している(であろう)

という動作をしました。multipart/form-dataの指定あり/なし、いずれの場合も同じです。また、mbstring.strict_encodingの値は、関係ないようです。ちょっと納得はしてませんが。。。自動的にエンコーディング変換されてる感じでしょうか?
確認した環境は以下の通りです。

  • CentOS4.4
  • Apache2.2.4+PHP5.2.1/Apache2.0.59+PHP5.2.1
    • PHP5.2.1はIlia氏のダウンロードスペースから取得
  • ./configure --with-apxs2=/usr/local/apache2/bin/apxs --prefix=/usr/local/lib/php5 --with-pear=/usr/local/lib/php5/pear --with-config-file-path=/usr/local/lib/php5/ini/5.2.1 --with-config-file-scan-dir=/usr/local/lib/php5/ini.d --enable-zend-multibyte --enable-mbstring --enable-mbregex --with-dom --with-gd=shared --with-jpeg-dir --with-png-dir --with-zlib-dir --with-ttf --with-freetype-dir --enable-gd-jis-conv --enable-soap=shared --with-pdo=shared --with-pdo-sqlite=shared --with-pspell=shared --enable-debug --with-openssl=shared --with-mysql=shared --with-pdo-mysql=shared --enable-curl=shared