1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
#!/usr/bin/perl
#BEGIN{
# print "Content-type: text/plainnn";
# open(STDERR, ">&STDOUT");
# $|=1;
#}
$timeBegin = times;
unshift(@INC, "../..");# 「jcode.pl」のあるディレクトリ
require "jcode.pl";
use Jcode;
$info_mailName = 'Nobu3';
$info_mailAddr = 'nobu3@x.age.ne.jp';
$info_uriName = 'Incomprehensible Perl Project';
$info_uriAddr = 'http://www.age.ne.jp/x/nobu3/perl/';
$info_uri = qq(<a href="$info_uriAddr">$info_uriName</a>.);
$info_mail = qq((C)1999 - 2000 <a href="mailto:$info_mailAddr">$info_mailName</a>. All rights reserved.);
$info_copyright = "<address>n<font face=times>$info_uri<br>n$info_mail</font><br>n</address>n";
@usr_stylesheet = ('/Nobu3/ipp.css','../test.css');# できあがりからのURIパス
$usr_outcode = 'jis';
$usr_outCharset = 'iso-2022-jp';
$usr_title = 'テスト24';
$explain = $ENV{SCRIPT_NAME};
$explain =~ s|cgi/(ts[0-9]{4})(_[12u])?.cgi$|$1.htm|;
$explain_title = $usr_title . 'の解説';
%usr_links = (# リンクネーム => リンクアドレス
'Home' => '../../../index.htm'
, 'Perl' => '../../'
, 'TestCGI Index' => '../'
, $explain_title => $explain
);
{
printHeader($usr_title);
printBodyHeader($usr_title);
print "<div class=test>n";
# require "dumpvar.pl"; dumpValue(%usr_links);
print "Jcode $Jcode::VERSION<br>n";
$japanese = "日本語に変換する文字列。<br>n";
print useJcode($japanese);
print Jcode->new('これも日本語<br>')->jis;
$hoge = 'ほげほげほ?';
print Jcode::convert($hoge, $usr_outcode);
$geho = 'げほげほげ?';
print Jcode::convert($geho, $usr_outcode);
print $geho;
print "<br><br>n";
print "jcode.pl $jcode::version<br>n";
print usejcode($japanese);
print jcode::convert('これも日本語<br>', $usr_outcode);
$hoge = 'ほげほげほ?';
print jcode::convert($hoge, $usr_outcode);
$geho = 'げほげほげ?';
print jcode::convert($geho, $usr_outcode);
print $geho;
print "<br>n";
print "</div>n";
printFooter();
exit(0);
}
sub useJcode{
my($str)= @_;
return Jcode->new($str)->jis;
}
sub usejcode{
my($str) = @_;
jcode::convert($str, $usr_outcode);
return $str;
}
sub error{
my($err) = shift;
printHeader($err);
printBodyHeader($err.'です');
Jprint(@_);
printFooter();
exit(1);
}
sub printHeader{
# 「<title>タグ」の文字列
my($title) = @_;
print "Content-type: text/html; charset=$usr_outCharsetnn";
print qq(<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">n);
print "<html lang=ja>n<head>n";
print qq(<meta http-equiv="Content-type" content="text/html; charset=$usr_outCharset">n);
print qq(<meta http-equiv="Content-style-type" content="text/css">n);
Jprint("<title>$title</title>n");
print qq(<link rev="made" href="$info_mailAddr">n);
foreach(@usr_stylesheet){ print qq(<link rel="stylesheet" type="text/css" href="$_">n); }
print qq(<meta name="ROBOTS" content="NOINDEX">n);
print "</head>nn";
print "<body>nn";
}
sub printBodyHeader{
# 英字なら「printBodyHeader("<font face=times>Title String</font>");」がいい
my($title) = @_;
print "<div align=center>n";
Jprint(qq(<h1><a name="top">$title</a></h1>n<hr>n));
printLinks();
print "</div>n";
}
sub printFooter{
print "<div align=center>n";
print qq(<a href="#top">Top</a>n<hr>n);
printLinks();
print "</div>n";
print "n<div align=right>n";
$timeEnd = sprintf("%.3f", times - $timeBegin);
print "Cost : $timeEnd<br>n";
print $info_copyright;
print "n</body>n</html>nn";
}
sub printLinks{
my $cnt = 0;
foreach(keys %usr_links){
print "/ " if($cnt++);
Jprint(qq(<a href="$usr_links{$_}">$_</a>n));
}
print "<hr>n";
}
sub Jprint{
foreach(@_){
my $tmp = $_;
jcode::convert($tmp, $usr_outcode);
print $tmp;
}
}
|