PHPバージョンアップ

PHP4→5への検証を(お金がないので)自分でやってみた

1.文字化け
mb_http_outputとob_startによる日本語表示

mb_http_output('EUC');
ob_start('mb_output_handler');


2.DBのエンコード指定(これは環境によるものか?)
デフォルトで設定されていたので指定


WEBシステム開発|PHPとPostgreSQLの開発例

  pg_set_client_encoding($con, 'UTF-8');


3.廃止関数のラッパー作成
PHP5へのポーティング

function i18n_convert($str, $to_encoding, $from_encoding  = null)
{
    if (is_null($from_encoding)) {
        return mb_convert_encoding($str, $to_encoding, "SJIS");
    } else {
        return mb_convert_encoding($str, $to_encoding, $from_encoding);
    }
}


function i18n_ja_jp_hantozen($str, $option, $encoding = null)
{
    if (is_null($encoding)) {
        return mb_convert_kana($str, $option, "SJIS");
    } else {
        return mb_convert_kana($str, $option, $encoding);
    }
}

なんという突貫工事。