#!/usr/local/bin/perl
# ★注意:このソースは UTF-8 にて保存
# ----------------------------------------------------------------------
# 外字入力アプレットの結果表示CGI
# フォーム入力されたデータを格納
if ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } else { $buffer = $ENV{'QUERY_STRING'}; }
# デバッグ用ログ(test_input.txt)を出力する場合は下記を「1」にする
$debug = 0;
# ローカルタイムのスタンプ用
($sec,$min,$hour,$day,$mon,$year,$wday,$yday)=localtime(time);
$year+=1900;
$mon++;
# 入力されたデータを文字列に代入・コード変換する
@pairs = split(/&/,$buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
# 入力文字を取り出し
$EudcText = $FORM{'EudcText'};
# 入力確認用のHTLM編集
$html = << "HTML";
外字テスト
入力した外字文字
[戻る]
HTML
# HTML 出力
print "Content-type: text/html\n\n";
print $html;
# 入力データをロギング (デバッグ用)
if ($debug == 1) {
$date=sprintf("%04d/%02d/%02d-%02d:%02d:%02d",$year,$mon,$day,$hour,$min,$sec);
open(F,">> test_input.txt");
print F "$date - $EudcText\r\n";
close(F);
}
exit;