1 |
<?xml version="1.0" encoding="iso-2022-jp"?> |
2 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" |
3 |
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> |
4 |
<html xml:lang="ja" xmlns="http://www.w3.org/1999/xhtml"> |
5 |
<head> |
6 |
<title xml:lang="en">Message::* Perl modules</title> |
7 |
<link rel="index" href="./" /> |
8 |
<?xml-stylesheet href="/s/simpledoc"?> |
9 |
<link rel="stylesheet" href="/s/simpledoc" /> |
10 |
<link rev="made" href="mailto:w@suika.fam.cx" /> |
11 |
<link rel="copyright" href="/c/pd" title="Public Domain." /> |
12 |
<meta name="author" content="$B<cMU(B" /> |
13 |
<meta name="keywords" content="Perl, module, pm, Message, RFC 822, RFC 2822, RFC 1036, son-of-RFC 1036, MIME, Usefor, HTTP, CGI, header, field" /> |
14 |
</head> |
15 |
<body> |
16 |
<h1>Message::* Perl modules</h1> |
17 |
|
18 |
<h2>$B$O$8$a$N$O$8$a$K(B</h2> |
19 |
|
20 |
<p>$B$?$H$($P(B Perl $B$G=q$+$l$?(B CGI script, $B$=$l$b7G<(HD$J$s$+$K$O!"(B |
21 |
$B$3$s$J$/$@$i$J$$(B code $B$,:\$C$F$$$?$j$7$^$9!#(B</p> |
22 |
|
23 |
<pre class="application-x-perl"> |
24 |
jcode'convert(*from, "jis"); |
25 |
jcode'convert(*subject, "jis"); |
26 |
jcode'convert(*message, "jis"); |
27 |
open (MAIL, "| $sendmail"); |
28 |
print MAIL "From: $mail ($from)\n"; |
29 |
print MAIL "To: $mailto\n"; |
30 |
print MAIL "Subject: $subject\n"; |
31 |
print MAIL "\n"; |
32 |
print MAIL "$message"; |
33 |
print MAIL "\n"; |
34 |
close (MAIL); |
35 |
</pre> |
36 |
|
37 |
<p>$B$3$l$G$O;kG'@-$bNI$/$J$$$G$9$7!"$&$C$+$j=$@5$74V0c$($k$H(B |
38 |
$BJQ$J%a%C%;!<%8$rAw?.$7$F$7$^$$$^$9!#(B |
39 |
($BI.<T$O$7$g$C$A$e$&$O$^$C$F$^$7$?(B:-) |
40 |
($B$=$l$KB?$/$N(B code $B$G$O!"(B |
41 |
HTML $B$G$N%/%m%9%5%$%H%9%/%j%W%F%#%s%0(B (CSS) $BLdBj$H(B |
42 |
$BN`;w$NLdBj$X$NBP=h$r$7$F$$$^$;$s!#(B)</p> |
43 |
|
44 |
<p>$B%*%V%8%'%/%H;X8~$r<h$jF~$l$F<!$N$h$&$J46$8$G%a%C%;!<%8$r(B |
45 |
$B9=@.$7$?$$$H$3$m$G$9!#(B</p> |
46 |
|
47 |
<pre class="application-x-perl"> |
48 |
use Message::Entity; |
49 |
my $msg = new Message::Entity; |
50 |
my $hdr = $msg->header; |
51 |
$hdr->add ('From')->add ('me@bar.example'); |
52 |
$hdr->add ('To')->add ('foo@bar.example', display_name => 'Mr. foo'); |
53 |
$hdr->add ('Subject' => $subject); |
54 |
$msg->body ($body); |
55 |
|
56 |
# $smtp->send $B$O(B SMTP $B$GAw?.$9$k(B method $B$H2>Dj!#(B |
57 |
$smtp->send ($msg); |
58 |
</pre> |
59 |
|
60 |
<p><a href="http://www.cpan.org/" xml:lang="en">CPAN</a> $B$rC5$9$H!"(B |
61 |
$B$3$l$K;w$?$h$&$J$3$H$,$G$-$=$&$J%b%8%e!<%k$O$"$k$h$&$G$9$,!"(B |
62 |
$B<B:]$K;H$C$F$_$k$H!"M?$($kCM$K$h$C$F$O(B <a href="urn:ietf:rfc:822">RFC 822</a>/<a href="urn:ietf:rfc:2822">2822</a> $B$K0cH?$9$k(B |
63 |
$B7k2L$r=PNO$9$k$J$I$NITK~$,$"$j$^$9!#(B ($BNc$($P:#$NNc$G(B |
64 |
<code xml:lang="en">To:</code> $BNN0h$K;H$C$F$$$k(B |
65 |
<code xml:lang="en">display_name</code> $B$G!V(B.$B!W$,4^$^$l$^$9$,!"(B |
66 |
RFC 2822 $BE*$K$O?7$7$$%a%C%;!<%8$G$O8_49@-$N$?$a(B |
67 |
<code xml:lang="en" class="bnf rfc2822">quoted-string</code> |
68 |
$B$K$9$kI,MW$,$"$j$^$9!#$7$+$7$=$N$^$^=PNO$5$l$^$9!#(B)</p> |
69 |
|
70 |
<p class="note">$B;29M(B: $B!V(B.$B!W$N>l9g$O(B RFC 2822 $BE*$K$O@5$7$/2r<a(B |
71 |
$B$5$l$J$1$l$P$J$j$^$;$s$,(B ($B=PNO$O$9$Y$-$G$J$$(B)$B!"(B |
72 |
$B$3$l0J30$NJ8;z!"Nc$($P@)8fJ8;z(B <code class="character">ESCAPE</code> $B$G$bF1$8$h$&$K$J$j$^$9!#(B |
73 |
$B$3$A$i$O40A4$K4V0c$$$G$9!#(B</p> |
74 |
<p class="note">$B;29M(B: $B<BAuJ}?K$H$7$F$OIT@5$JCM$O%b%8%e!<%k$K(B |
75 |
$BEO$9A0$KCF$/$Y$-$H$$$&9M$(J}$b$"$k$G$7$g$&!#(B |
76 |
$B$G$b$=$s$J$N$OITJX$G$9!#(B</p> |
77 |
|
78 |
<p>$B$H$$$&$3$H$G!"$O$8$a$O4{B8$N%b%8%e!<%k$N(B wrapper ($B$"$k$$$OJd40(B) |
79 |
$B$r=q$/$D$b$j$G$7$?$,!"$J$s$@$+$4$A$c$4$A$c$7$F$$$F!"(B |
80 |
$B$=$l$J$i<VNX$N:FH/L@$K$J$C$F$b0l$+$i=q$$$F$_$h$&$H9M$($^$7$?!#(B</p> |
81 |
|
82 |
<h2>$BFC?'(B ($B$H$$$&Dx$N$b$N$G$b$J$$!#(B)</h2> |
83 |
|
84 |
<ol> |
85 |
<li>$B7k9=(B($BFf(B)$B%*%V%8%'%/%H;X8~$G$9!#(B</li> |
86 |
<li>RFC 822/2822 $B$N(B <code class="bnf rfc2822">group</code> $B$r2r<a=PMh$^$9!#(B</li> |
87 |
<li><a href="urn:ietf:id:draft-ietf-usefor-msg-id-alt-00">draft-ietf-usefor-msg-id-alt-00</a> $B$K4p$E$$$?Aw?.%"%I%l%9$J$I$K$h$k(B <code class="rfc2822">Message-ID</code> $B$r@8@.=PMh$^$9!#(B</li> |
88 |
<li>$BJ8;z%3!<%IFHN)(B (CSI) $B$G$9!#(B ($BC"$7(B RFC 822 $B$G$"$kET9g>e(B($BFf(B)$B!"(B |
89 |
ASCII $B8_49$G$"$kI,MW$O$"$j$^$9!#(B EBCDIC $B$H$+$OL5M}$G$9(B:-<)</li> |
90 |
</ol> |
91 |
|
92 |
<h2>$B3F;EMM$X$NBP1~>u67(B</h2> |
93 |
|
94 |
<ol> |
95 |
<li>$BEE;R%a%$%k$N%a%C%;!<%8(B (RFC 822, RFC 2822) |
96 |
$B$NA45!G=$K(B ($BH4$1$,L5$1$l$P(B) $BBP1~$7$F$$$^$9!#(B |
97 |
$BC"$7D9$5@)8B$J$I$O%A%'%C%/$7$F$$$^$;$s!#(B (MIME $B$N(B |
98 |
<code class="mime">Content-Transfer-Encoding</code> |
99 |
$B$H0l=o$K<BAuM=Dj(B)</li> |
100 |
<li>$BEE;R%K%e!<%95-;v(B (<a href="/uri-res/N2L?urn:ietf:rfc:1036">RFC 1036</a>, |
101 |
<a href="spec/son-of-RFC1036">son-of-RFC1036</a>, |
102 |
<a href="/uri-res/N2L?urn:ietf:id:draft-usefor-article-06"> |
103 |
draft-usefor-article (06)</a>) $B$NF,NN0h$NB?$/$KBP1~$7$F$$$^$9!#(B</li> |
104 |
<li>MIME $B$NK\BNItJ,(B (body part) $B$K$O$^$@BP1~$7$F$$$^$;$s!#(B</li> |
105 |
<li>MIME $B$NDI2CF,NN0h(B |
106 |
(<a href="/uri-res/N2L?urn:ietf:rfc:2045">RFC 2045</a>, |
107 |
<code class="mime">Content-Disposition</code>) $B$KBP1~$7$F$$$^$9!#(B |
108 |
$B%Q%i%a!<%?!<CM3HD%(B (<a href="/uri-res/N2L?urn:ietf:rfc:2231">RFC 2231</a>) |
109 |
$B$bF~=PNO$H$b$K<BAu$7$^$7$?!#(B</li> |
110 |
<li>MIME $BId9f2=8l(B (<code class="mime bnf">encoded-word</code>) |
111 |
$B$N2rFI$KBP1~$7$F$$$^$9(B:-) $BC"$7JLESJQ49=hM}$r;XDj$9$kI,MW$,$"$j$^$9!#(B |
112 |
(<a href="#code">$BJ8;z%3!<%I$N07$$(B</a>$B;2>H(B)</li> |
113 |
<li>HTTP/1.0, HTTP/1.1, CGI/1.1, CGI/1.2 $B$NF,NN0h$N$&$A!"(B |
114 |
$B$4$/0lIt$KBP1~$7$F$$$^$9!#(B MHTML $B$N(B |
115 |
<code class="mime">Content-Location</code> $B$K$bBP1~$7$F$$$^$9!#(B</li> |
116 |
<li>$BF|IU7A<0$G$O(B RFC 822/<a href="urn:ietf:rfc:1123">1123</a>, |
117 |
<a href="urn:ietf:rfc:733">RFC 733</a>, asctime, ISO 8601 (HTML) |
118 |
$B$J$I$KBP1~$7$F$$$^$9!#(B</li> |
119 |
</ol> |
120 |
|
121 |
<h2>$B@)8B;v9`(B</h2> |
122 |
|
123 |
<ol> |
124 |
<li>$BN`;w%b%8%e!<%k(B($BFf(B)$B$N$h$&$K!"%U%!%$%kL>$d%U%!%$%k!&%O%s%I%k$r(B |
125 |
$BEO$7$FFI$_9~$^$;$k$3$H$,=PMh$^$;$s!#(B</li> |
126 |
<li>$BBg$-$J%a%C%;!<%8$G$b0l5$$KFI$_9~$_!"A4$F<g5-21NN0h$G(B |
127 |
$BJ];}$7$F$$$^$9!#$G$9$+$i$"$^$jBg$-$J%a%C%;!<%8$N=hM}$K$O(B |
128 |
$B8~$$$F$$$J$$$G$7$g$&!#(B</li> |
129 |
<li><code>CR</code> $B$d(B <code>LF</code> $B$,C1BN$G=P8=$9$k>l9g!"(B |
130 |
$B@5$7$/=hM}=PMh$^$;$s!#(B (<code>CRLF</code> $B$HEy2A$H$_$J$7$^$9!#(B) |
131 |
$B>-Mh$NHG$G$O%*%W%7%g%s$G@)8f2DG=$K$J$k$+$b$7$l$^$;$s!#(B</li> |
132 |
<li>$B$"$C$?$iNI$5$=$&$J5!G=$,L$<BAu$+$b$7$l$^$;$s!#(B |
133 |
($BM_$7$$5!G=$,L$<BAu$@$C$?$i!"(B |
134 |
<a href="mailto:w@suika.fam.cx">$BEE;R%a%$%k(B</a>$B$J$I$G65$($F2<$5$$!#(B)</li> |
135 |
<li>$B3F%b%8%e!<%k$N%*%W%7%g%sBN7O$,$"$^$j@0Hw$5$l$F$$$^$;$s!#(B |
136 |
($B$=$l$G$b5$;}$A0-$/$J$$DxEY$K$OBN7OE*$@$H;W$$$^$9!#(B)</li> |
137 |
<li>$B@bL@J8(B (document) $B$,NI$$2C8:$G$9!#(B</li> |
138 |
</ol> |
139 |
|
140 |
<h2>$B:#8e$NM=Dj(B</h2> |
141 |
|
142 |
<ol> |
143 |
<li>$BEE;R%K%e!<%9$NF,NN0h(B (RFC 1036, |
144 |
<a href="spec/son-of-RFC1036">son-of-RFC1036</a>, |
145 |
draft-usefor-article) $B$N40A4<BAu(B</li> |
146 |
<li><del>MIME $B$NF,NN0h$N<BAu!#(B</del></li> |
147 |
<li>$BDI2C(B/$BHsI8=`$NF,NN0h$N<BAu!#(B</li> |
148 |
<li>MIME $BK\BN(B (<code class="bnf rfc822">body</code>) $B$N<BAu!#(B</li> |
149 |
<li><del>$BJ8;zId9fJQ49$N$?$a$N(B hook $B$N<BAu(B?</del></li> |
150 |
<li>documentation$B!#(B</li> |
151 |
<li>$B;HMQNc$N:n@.!#(B</li> |
152 |
</ol> |
153 |
|
154 |
<h2>$BI,MW4D6-(B</h2> |
155 |
|
156 |
<ol> |
157 |
<li>Perl (perl 5.6 $B0J9_$^$?$O(B<span title="human parser">$B?M4V2r@O<T(B</span>:-)) |
158 |
<p class="note"><code class="bnf rfc822">comment</code> |
159 |
$B$rI=$9$N$K@55,I=8=(B <code class="regex">(??{ <var>code</var> })</code> |
160 |
$B$r;H$C$F$$$k$N$G!"$3$l$r2r<a=PMh$k!"(B |
161 |
5.6 $B0J9_$NHG$G$"$kI,MW$,$"$j$^$9!#(B</p> |
162 |
</li> |
163 |
<li>Digest::MD2, Digest::MD5, Digest::SHA1 |
164 |
<p>Message-ID $B$N@8@.$K$3$l$i$r;HMQ$9$k>l9g$N$_!"(B |
165 |
<code>Message::Field::MsgID::MsgID</code> $B$,;H$$$^$9!#(B</p> |
166 |
<p>$B$3$l$i$,MQ0U$5$l$F$$$J$$4D6-$G$O%(%i!<$K$J$k$N$G!"(B |
167 |
($B8=>u$G$O(B) $B>e5-%b%8%e!<%k$N3:EvItJ,$r=q$-49$($FBP=h$7$F2<$5$$!#(B</p> |
168 |
</li> |
169 |
<li>$BJ8;z%3!<%IJQ49=hM}(B |
170 |
<p>$BF|K\8l%a%C%;!<%8$r07$&$J$iI,?\$G$7$g$&!#(B |
171 |
$B>\$7$/$O(B<a href="#code">$BJ8;z%3!<%I$N07$$(B</a> |
172 |
$B$N>O$r$4;2>H2<$5$$!#(B</p> |
173 |
</li> |
174 |
</ol> |
175 |
|
176 |
<h2>$BF~<j(B</h2> |
177 |
|
178 |
<p>suika.fam.cx $B$N(B SSH account $B$r$*;}$A$N>l9g!"(B CVS $B$+$iF~<j=PMh$^$9!#(B</p> |
179 |
|
180 |
<p class="example">$ cvs -d :ext:<var xml:lang="en">username</var>@suika.fam.cx:/home/cvs -d perl/lib/Message/</p> |
181 |
|
182 |
<p>Web $B$+$i$b<h$j=P$;$^$9!#(B <<a href="/gate/cvs/perl/lib/Message/">http://suika.fam.cx/gate/cvs/perl/lib/Message/</a>> (tarball $B$G0l3g<hF@$b=PMh$^$9!#(B)</p> |
183 |
|
184 |
<h2>$B%i%$%;%s%9(B</h2> |
185 |
|
186 |
<p>Message::* Perl modules $B$O<+M3%=%U%H%&%'%"$G$9!#(B |
187 |
GNU GPL $B$K=>$C$FMxMQ=PMh$^$9!#>\$7$/$O3F%U%!%$%k$r8fMw2<$5$$!#(B</p> |
188 |
|
189 |
<h2>$B;29MJ88%(B</h2> |
190 |
|
191 |
<ul> |
192 |
<li><a href="spec/">$B4XO"$9$k;EMM=q(B (RFC, Internet-Draft $BEy(B)</a></li> |
193 |
</ul> |
194 |
|
195 |
<h2 id="code">$BJ8;z%3!<%I$N07$$(B</h2> |
196 |
|
197 |
<p>$BH\$7$$$3$H$GF,$rG:$^$9$N$O7y$J$N$G(B($BON(B)$B!"(B |
198 |
Message::* $B$OId9f2=J}K!FHN)(B (CSI) $B$rL\;X$7$F<BAu$7$F$$$^$9!#(B |
199 |
($BC"$7(B ASCII $B$N$7$,$i$_$@$1$OCG$A@Z$C$F$$$^$;$s(B:-)) |
200 |
0x00 $B!A(B 0x7F $B$,(B ASCII ($B$^$?$O(B ASCII $B$H8+$J$7$FNI$$$b$N(B) $B$G$"$k(B |
201 |
$B>l9g$O!"(B Message::* $B$rDL$7$?$3$H$G%G!<%?$,2u$l$k$3$H$O(B |
202 |
$BL5$$$H;W$$$^$9!#(B</p> |
203 |
|
204 |
<p>($B$b$A$m$s!"(B RFC 822 $B$J$I3F;EMM$K>H$i$7$F@5E}(B($BE*(B)$B$G(B |
205 |
$B$"$kI,MW$,$"$j$^$9!#(B <code class="bnf rfc822">atom</code> |
206 |
$B$K(B8$B%S%C%H!&%3!<%I$,4^$^$l$F$$$k$H@5$7$/07$($^$;$s!#(B) |
207 |
($BAa$$OC$,!"(B <code class="bnf rfc822">quoted-string</code> |
208 |
$B$J$I$G$O(B8$B%S%C%HF)2a$@$H$$$&$3$H$G$9!#2s$j$/$I$/$F$4$a$s$J$5$$!#(B)</p> |
209 |
|
210 |
<p>$B4{Dj$N>uBV$G$OJ8;z%3!<%I$K4X78$9$kJQ49=hM}$O9T$o$l$^$;$s!#(B |
211 |
$B$7$+$7!"%U%C%/4X?t$C$]$$$b$N(B($BFf(B)$B$r;XDj$9$k$3$H$G!"(B |
212 |
$BJQ49=hM}$r$5$;$i$l$^$9!#(B</p> |
213 |
|
214 |
<p>$B;XDj=PMh$k%U%C%/4X?t$C$]$$$b$N$O(B2$B<oN`$G$9!#(B |
215 |
<code>DECODER</code> $B$O!"85$N%a%C%;!<%8$r2r@O$9$k;~(B |
216 |
(<code class="perl">parse ()</code>) $B$KE,598F$S=P$5$l$^$9!#(B |
217 |
<code>ENCODER</code> $B$O!"%a%C%;!<%8$H$7$FJ8;zNs2=$9$k:](B |
218 |
(<code class="perl">stringify ()</code> $B$J$I(B) $B$KE,598F$S=P$5$l$^$9!#(B</p> |
219 |
|
220 |
<p>$B$3$l$i$N4X?t$O!"EvA3!"Ev3:=hM}$,8F$S=P$5$l$kA0$K;XDj$7$F$*$/(B |
221 |
$BI,MW$,$"$j$^$9!#(B |
222 |
<samp class="perl">Message::Entity->parse</samp> $B$J$I$9$kA0$K(B |
223 |
$BDj5A$7$F$*$/$HNI$$$G$7$g$&!#(B</p> |
224 |
|
225 |
<pre class="example perl"> |
226 |
require Message::MIME::Charset; |
227 |
$Message::MIME::Charset::DECODER{'*default'} = sub {jcode::euc ($_[1])}; |
228 |
$Message::MIME::Charset::ENCODER{'*default'} = sub {jcode::jis ($_[1], 'euc')}; |
229 |
</pre> |
230 |
|
231 |
<p>$B$3$NNc$G$O!"(B jcode.pl $B$rJQ49=hM}$K;H$$$^$9!#(B |
232 |
($B$b$A$m$s!"4{$K(B <code class="perl">require</code> |
233 |
$B$5$l$F$$$k$H2>Dj$7$F$$$^$9!#(B)</p> |
234 |
<p>$B:G=i$N(B <code class="perl">require</code> $B$G!"JQ49=hM}$rC4Ev$7$F$$$k(B |
235 |
<code class="perl">Message::MIME::Charset</code> $B$rFI$_9~$_$^$9!#(B |
236 |
($B$3$&$7$F$*$+$J$$$H!"8e$+$i4{DjCM(B (= $BL5JQ49(B) $B$G(B |
237 |
<code class="perl">*default</code> $B$,>e=q$-$5$l$F$7$^$$$^$9!#(B)</p> |
238 |
|
239 |
<p>$B$3$N(B code $B$r;H$C$?%9%/%j%W%H$OFbIt=hM}$rF|K\8l(B EUC |
240 |
$B$G9T$&$H2>Dj$7$F$$$^$9!#$G$9$+$i!"(B <code class="perl">DECODER</code> |
241 |
$B$GF|K\8l(B EUC $B$KJQ49$7$^$9!#(B</p> |
242 |
<p>$B$^$?!"F|K\8l%a%C%;!<%8$G$O(B <code>ISO-2022-JP</code> |
243 |
$B$r;H$&$N$,47=,$G$9$+$i!"(B <code class="perl">ENCODER</code> |
244 |
$B$G$O(B 7$B%S%C%H(B JIS $B$KJQ49$7$F$$$^$9!#(B</p> |
245 |
<p>$B=hM}$r9T$&4X?t$O!"0z?t$,(B2$B$D0J>eM?$($i$l$^$9!#(B |
246 |
1$B$DL\$N0z?t$O8F$S=P$7$?(B class module, $B$$$o$f$k(B |
247 |
<code class="perl">$self</code> $B$G$9!#(B($B$3$N>l9g(B self $B$G$O$"$j$^$;$s$,(B:-) |
248 |
$B$G$bIaDL$OI,MW$J$$$G$7$g$&!#(B</p> |
249 |
<p>2$B$DL\$N0z?t$O=hM}BP>]$NJ8;zNs$G$9!#(B</p> |
250 |
<p>3$B$DL\0J9_$N0z?t$O!"DI2C%*%W%7%g%s$N%O%C%7%e$G$9!#(B |
251 |
$B$?$@$7!"8=:_DI2C%*%W%7%g%s$ODj5A$5$l$F$$$^$;$s!#(B</p> |
252 |
<p>$B4X?t$,JV$9CM$O(B($B:#$N$H$3$m(B)$B0l$D$@$1$G$9!#(B |
253 |
$B=hM}$,=*$o$C$?J8;zNs$G$9!#JQ497k2L$H$7$F2?$b$J$/$J$C$F$7$^$C$?$i!"(B |
254 |
$B$b$A$m$s6uJ8;zNs$rJV$7$F9=$$$^$;$s!#(B (<code class="perl">undef</code> |
255 |
$B$h$j$b6uJ8;zNs$NJ}$,K>$^$7$$$G$7$g$&!#(B)</p> |
256 |
|
257 |
<p>$B$5$F!">e5-$NNc$G$O!V(B<code>*default</code>$B!W$N(B EN/DECODER |
258 |
$B$r;XDj$7$^$7$?$,!"$3$3$K$OBe$o$j$K(B charset $BL>$r;XDj=PMh$^$9!#(B</p> |
259 |
|
260 |
<pre class="perl example"> |
261 |
$Message::MIME::Charset::DECODER{'iso-2022-jp'} = sub {jcode::euc ($_[1], 'jis')}; |
262 |
</pre> |
263 |
|
264 |
<p>$B$3$3$G$O!"(B <code>ISO-2022-JP</code> $B$rFbIt%3!<%I$KJQ49$9$k(B |
265 |
$BJ}K!$rDj5A$7$F$$$^$9!#(B charset $BL>(B ($B$*$h$S!V(B<code>*default</code>$B!W(B |
266 |
$B$OI,$:>.J8;z$G=q$$$F2<$5$$(B!)</p> |
267 |
<p>MIME body $B$d!"(B encoded-word, RFC 2231 $B$N3HD%%Q%i%a!<%?!<CM(B |
268 |
$B$J$I!"(B charset $B$,;XDj$5$l$F$$$k;~$O$=$N(B charset $BL>$NJQ494X?t$,(B |
269 |
$B8F$S=P$5$l$^$9!#(B ($B;XDj$5$l$?(B charset $BL>$NJQ494X?t$,L$Dj5A$N;~$O!"(B |
270 |
$B2?$b=hM}$7$^$;$s!#(B) $B$3$l0J30$N>lLL$G$O!"(B <code>*default</code> |
271 |
$B$GDj5A$5$l$?4X?t$,;H$o$l$^$9!#(B</p> |
272 |
|
273 |
<p>$B:G8e$K!"F|K\8l%a%C%;!<%8$r07$&:]$NNc$r5s$2$F$*$-$^$9!#(B</p> |
274 |
|
275 |
<pre class="example perl"> |
276 |
<span class="comment">## jcode.pl $B$r;HMQ(B</span> |
277 |
require 'jcode.pl'; |
278 |
require Message::MIME::Charset; |
279 |
$Message::MIME::Charset::DECODER{'*default'} = sub {jcode::euc ($_[1])}; |
280 |
$Message::MIME::Charset::DECODER{'iso-2022-jp'} = sub {jcode::euc ($_[1], 'jis')}; |
281 |
$Message::MIME::Charset::DECODER{'euc-jp'} = sub {$_[1]}; |
282 |
$Message::MIME::Charset::DECODER{'shift_jis'} = sub {jcode::euc ($_[1], 'sjis')}; |
283 |
$Message::MIME::Charset::ENCODER{'*default'} = sub { |
284 |
my $s = $_[1]; |
285 |
<span class="comment">## $B@55,2=(B</span> |
286 |
jcode::tr(\$s, |
287 |
"\xa3\xb0-\xa3\xb9\xa3\xc1-\xa3\xda\xa3\xe1-\xa3\xfa\xa1\xf5". |
288 |
"\xa1\xa4\xa1\xa5\xa1\xa7\xa1\xa8\xa1\xa9\xa1\xaa\xa1\xae". |
289 |
"\xa1\xb0\xa1\xb2\xa1\xbf\xa1\xc3\xa1\xca\xa1\xcb\xa1\xce". |
290 |
"\xa1\xcf\xa1\xd0\xa1\xd1\xa1\xdc\xa1\xf0\xa1\xf3\xa1\xf4". |
291 |
"\xa1\xf6\xa1\xf7\xa1\xe1\xa2\xaf\xa2\xb0\xa2\xb2\xa2\xb1". |
292 |
"\xa1\xe4\xa1\xe3\xA1\xC0\xA1\xA1" |
293 |
=> '0-9A-Za-z&,.:;?!`^_/|()[]{}+$%#*@=\'"~-><\\ '); |
294 |
jcode::jis ($s, 'euc', 'z') |
295 |
}; |
296 |
</pre> |
297 |
|
298 |
<pre class="example perl"> |
299 |
<span class="comment">## Jcode.pm $B$r;HMQ(B</span> |
300 |
use Jcode; |
301 |
require Message::MIME::Charset; |
302 |
$Message::MIME::Charset::DECODER{'*default'} = sub {jcode::euc ($_[1])}; |
303 |
$Message::MIME::Charset::DECODER{'iso-2022-jp'} = sub {Jcode->new ($_[1], 'jis')->euc}; |
304 |
$Message::MIME::Charset::DECODER{'euc-jp'} = sub {$_[1]}; |
305 |
$Message::MIME::Charset::DECODER{'shift_jis'} = sub {Jcode->new ($_[1], 'sjis')->euc}; |
306 |
$Message::MIME::Charset::DECODER{'utf-8'} = sub {Jcode->new ($_[1], 'utf8')->euc}; |
307 |
$Message::MIME::Charset::ENCODER{'*default'} = sub {Jcode->new ($_[1], 'euc')->jis}; |
308 |
$Message::MIME::Charset::ENCODER{'utf-8'} = sub {Jcode->new ($_[1], 'euc')->utf8}; |
309 |
</pre> |
310 |
|
311 |
<p>Perl 5.8 $B$G(B Encode $B%b%8%e!<%k$,;H$($k$h$&$K$J$l$P!"(B |
312 |
$B$b$C$H3Z$K$J$k$H4|BT$7$F$$$^$9!#(B</p> |
313 |
|
314 |
<div class="navigation"> |
315 |
[<a href="/" title="$B$3$N%5!<%P!<$N<sJG(B">/</a> |
316 |
<a href="/map" title="$B$3$N%5!<%P!<$N0FFb(B" rel="index">$BCO?^(B</a> |
317 |
<a href="/search/" title="$B$3$N%5!<%P!<$N8!:w(B">$B8!:w(B</a>] |
318 |
<a href="http://validator.w3.org/check/referer" xml:lang="en"><img |
319 |
src="http://www.w3.org/Icons/valid-xhtml11" id="w3c-html" |
320 |
alt="Valid XHTML 1.1!" style="height: 31px; width: 88px" /></a> |
321 |
<a href="http://jigsaw.w3.org/css-validator/validator?uri=http://suika.fam.cx/~wakaba/Message-pm/introduction.ja.html" xml:lang="en"> |
322 |
<img style="width: 88px; height: 31px" id="w3c-css" |
323 |
src="http://jigsaw.w3.org/css-validator/images/vcss" |
324 |
alt="Valid CSS!" /></a> |
325 |
</div> |
326 |
<div class="update">$Date: 2002/04/01 09:21:23 $</div> |
327 |
<ul class="myuri"> |
328 |
<li><URL:<a href="http://suika.fam.cx/~wakaba/Message-pm/introduction">http://suika.fam.cx/~wakaba/Message-pm/introduction</a>></li> |
329 |
<li><CVS:<a href="http://suika.fam.cx/gate/cvs/perl/web/Message-pm/">suika.fam.cx:/home/cvs/perl/web/Message-pm/</a>></li> |
330 |
</ul> |
331 |
</body></html> |