Check

UTF8 -> JIS(ISO-2022-JP)変換(完成コード)

| | コメント(0) | トラックバック(1)

結局こんな形に。
もちろん半分はパクリ。
下半分はよくある人名漢字。

2008/07/10 「半角「」ってなに?」の修正を反映


function replaceText ( $str ) {
$arr = array(
"\xE2\x85\xA0" => "I",
"\xE2\x85\xA1" => "II",
"\xE2\x85\xA2" => "III",
"\xE2\x85\xA3" => "IV",
"\xE2\x85\xA4" => "V",
"\xE2\x85\xA5" => "VI",
"\xE2\x85\xA6" => "VII",
"\xE2\x85\xA7" => "VIII",
"\xE2\x85\xA8" => "IX",
"\xE2\x85\xA9" => "X",
"\xE2\x85\xB0" => "i",
"\xE2\x85\xB1" => "ii",
"\xE2\x85\xB2" => "iii",
"\xE2\x85\xB3" => "iv",
"\xE2\x85\xB4" => "v",
"\xE2\x85\xB5" => "vi",
"\xE2\x85\xB6" => "vii",
"\xE2\x85\xB7" => "viii",
"\xE2\x85\xB8" => "ix",
"\xE2\x85\xB9" => "x",
"\xE2\x91\xA0" => "(1)",
"\xE2\x91\xA1" => "(2)",
"\xE2\x91\xA2" => "(3)",
"\xE2\x91\xA3" => "(4)",
"\xE2\x91\xA4" => "(5)",
"\xE2\x91\xA5" => "(6)",
"\xE2\x91\xA6" => "(7)",
"\xE2\x91\xA7" => "(8)",
"\xE2\x91\xA8" => "(9)",
"\xE2\x91\xA9" => "(10)",
"\xE2\x91\xAA" => "(11)",
"\xE2\x91\xAB" => "(12)",
"\xE2\x91\xAC" => "(13)",
"\xE2\x91\xAD" => "(14)",
"\xE2\x91\xAE" => "(15)",
"\xE2\x91\xAF" => "(16)",
"\xE2\x91\xB0" => "(17)",
"\xE2\x91\xB1" => "(18)",
"\xE2\x91\xB2" => "(19)",
"\xE2\x91\xB3" => "(20)",
"\xE3\x8A\xA4" => "(上)",
"\xE3\x8A\xA5" => "(中)",
"\xE3\x8A\xA6" => "(下)",
"\xE3\x8A\xA7" => "(左)",
"\xE3\x8A\xA8" => "(右)",
"\xE3\x8D\x89" => "ミリ",
"\xE3\x8D\x8D" => "メートル",
"\xE3\x8C\x94" => "キロ",
"\xE3\x8C\x98" => "グラム",
"\xE3\x8C\xA7" => "トン",
"\xE3\x8C\xA6" => "ドル",
"\xE3\x8D\x91" => "リットル",
"\xE3\x8C\xAB" => "パーセント",
"\xE3\x8C\xA2" => "センチ",
"\xE3\x8E\x9D" => "cm",
"\xE3\x8E\x8F" => "kg",
"\xE3\x8E\xA1" => "m2",
"\xE3\x8F\x8D" => "K.K.",
"\xE2\x84\xA1" => "TEL",
"\xE2\x84\x96" => "No.",
"\xE3\x8D\xBB" => "平成",
"\xE3\x8D\xBC" => "昭和",
"\xE3\x8D\xBD" => "大正",
"\xE3\x8D\xBE" => "明治",
"\xE3\x88\xB1" => "(株)",
"\xE3\x88\xB2" => "(有)",
"\xE3\x88\xB9" => "(代)",
"\xE5\xBE\xB7" => "\xE5\xBE\xB3",
"\xE6\xBF\xB5" => "\xE6\xBF\xB1",
"\xE9\xAB\x99" => "\xE9\xAB\x98",
"\xE6\xA0\x81" => "\xE6\x9F\xB3",
"\xEF\xA4\xA9" => "\xE6\x9C\x97",
"\xEF\xA7\x9C" => "\xE9\x9A\x86",
"\xEF\xA8\x90" => "\xE5\xA1\x9A",
"\xEF\xA8\x91" => "\xE5\xB4\x8E",
"\xEF\xA8\x92" => "\xE6\x99\xB4",
"\xEF\xA8\x94" => "\xE6\xAC\x85",
"\xEF\xA8\x95" => "\xE7\x85\x95",
"\xEF\xA8\x96" => "\xE7\x8C\xAA",
"\xEF\xA8\x97" => "\xE7\x9B\x8A",
"\xEF\xA8\x98" => "\xE7\xA4\xBC",
"\xEF\xA8\x99" => "\xE7\xA5\x9E",
"\xEF\xA8\x9A" => "\xE7\xA5\xA5",
"\xEF\xA8\x9B" => "\xE7\xA6\x8F",
"\xEF\xA8\x9C" => "\xE9\x9D\x96",
"\xEF\xA8\x9D" => "\xE7\xB2\xBE",
"\xEF\xA8\x9E" => "\xE7\xBE\xBD",
"\xEF\xA8\xA2" => "\xE8\xAB\xB8",
"\xEF\xA8\xA5" => "\xE9\x80\xB8",
"\xEF\xA8\xA6" => "\xE9\x83\xBD",
"\xEF\xA8\xAA" => "\xE9\xA3\xAF",
"\xEF\xA8\xAB" => "\xE9\xA3\xBC",
"\xEF\xA8\xAC" => "\xE9\xA4\xA8",
"\xEF\xA8\xAD" => "\xE9\xB6\xB4",
"\xEF\xA8\x90" => "\xE5\xA1\x9A",
"\xE5\xA2\x9E" => "\xE5\xA2\x97",
"\xE5\xAF\xAC" => "\xE5\xAF\x9B",
"\xE6\x95\x8E" => "\xE6\x95\x99",
"\xEF\xA8\x92" => "\xE6\x99\xB4",
"\xEF\xA4\xA9" => "\xE6\x9C\x97",
"\xE6\xA9\xAB" => "\xE6\xA8\xAA",
"\xE6\xB7\xB8" => "\xE6\xB8\x85",
"\xE7\x80\xA8" => "\xE7\x80\xAC",
"\xEF\xA8\x96" => "\xE7\x8C\xAA",
"\xEF\xA8\x97" => "\xE7\x9B\x8A",
"\xEF\xA8\x99" => "\xE7\xA5\x9E",
"\xEF\xA8\x9A" => "\xE7\xA5\xA5",
"\xEF\xA8\x9B" => "\xE7\xA6\x8F",
"\xEF\xA8\x9C" => "\xE9\x9D\x96",
"\xEF\xA8\x9D" => "\xE7\xB2\xBE",
"\xE7\xB7\x96" => "\xE7\xB7\x92",
"\xEF\xA8\x9E" => "\xE7\xBE\xBD",
"\xE8\x96\xB0" => "\xE8\x96\xAB",
"\xEF\xA8\xA2" => "\xE8\xAB\xB8",
"\xE8\xB3\xB4" => "\xE9\xA0\xBC",
"\xE9\x83\x9E" => "\xE9\x83\x8E",
"\xEF\xA8\xA6" => "\xE9\x83\xBD",
"\xE9\x84\x95" => "\xE9\x83\xB7",
"\xE9\x96\x92" => "\xE9\x96\x93",
"\xEF\xA7\x9C" => "\xE9\x9A\x86",
"\xE9\x9D\x91" => "\xE9\x9D\x92",
"\xEF\xA8\xAA" => "\xE9\xA3\xAF",
"\xEF\xA8\xAB" => "\xE9\xA3\xBC",
"\xEF\xA8\xAC" => "\xE9\xA4\xA8",
"\xE9\xBB\x91" => "\xE9\xBB\x92",
"\xEF\xBD\xA2" => "\xE3\x80\x8C",
"\xEF\xBD\xA3" => "\xE3\x80\x8D", );
return str_replace( array_keys( $arr ), array_values( $arr ),
$str );
}

トラックバック(1)

このブログ記事を参照しているブログ一覧: UTF8 -> JIS(ISO-2022-JP)変換(完成コード)

このブログ記事に対するトラックバックURL: http://0-9.sakura.ne.jp/mt/mt-tb.cgi/131

以前作成したphpのmail用ライブラリで文字化け発生。内部はUTF-8なんです... 続きを読む

コメントする