1*0Sstevel@tonic-gate# 2*0Sstevel@tonic-gate# $Id: mime-header.t,v 1.8 2003/08/20 11:15:31 dankogai Exp $ 3*0Sstevel@tonic-gate# This script is written in utf8 4*0Sstevel@tonic-gate# 5*0Sstevel@tonic-gateBEGIN { 6*0Sstevel@tonic-gate if ($ENV{'PERL_CORE'}){ 7*0Sstevel@tonic-gate chdir 't'; 8*0Sstevel@tonic-gate unshift @INC, '../lib'; 9*0Sstevel@tonic-gate } 10*0Sstevel@tonic-gate require Config; import Config; 11*0Sstevel@tonic-gate if ($Config{'extensions'} !~ /\bEncode\b/) { 12*0Sstevel@tonic-gate print "1..0 # Skip: Encode was not built\n"; 13*0Sstevel@tonic-gate exit 0; 14*0Sstevel@tonic-gate } 15*0Sstevel@tonic-gate if (ord("A") == 193) { 16*0Sstevel@tonic-gate print "1..0 # Skip: EBCDIC\n"; 17*0Sstevel@tonic-gate exit 0; 18*0Sstevel@tonic-gate } 19*0Sstevel@tonic-gate $| = 1; 20*0Sstevel@tonic-gate} 21*0Sstevel@tonic-gate 22*0Sstevel@tonic-gateno utf8; 23*0Sstevel@tonic-gate 24*0Sstevel@tonic-gateuse strict; 25*0Sstevel@tonic-gate#use Test::More qw(no_plan); 26*0Sstevel@tonic-gateuse Test::More tests => 10; 27*0Sstevel@tonic-gateuse_ok("Encode::MIME::Header"); 28*0Sstevel@tonic-gate 29*0Sstevel@tonic-gatemy $eheader =<<'EOS'; 30*0Sstevel@tonic-gateFrom: =?US-ASCII?Q?Keith_Moore?= <moore@cs.utk.edu> 31*0Sstevel@tonic-gateTo: =?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?= <keld@dkuug.dk> 32*0Sstevel@tonic-gateCC: =?ISO-8859-1?Q?Andr=E9?= Pirard <PIRARD@vm1.ulg.ac.be> 33*0Sstevel@tonic-gateSubject: =?ISO-8859-1?B?SWYgeW91IGNhbiByZWFkIHRoaXMgeW8=?= 34*0Sstevel@tonic-gate =?ISO-8859-2?B?dSB1bmRlcnN0YW5kIHRoZSBleGFtcGxlLg==?= 35*0Sstevel@tonic-gateEOS 36*0Sstevel@tonic-gate 37*0Sstevel@tonic-gatemy $dheader=<<"EOS"; 38*0Sstevel@tonic-gateFrom: Keith Moore <moore\@cs.utk.edu> 39*0Sstevel@tonic-gateTo: Keld J\xF8rn Simonsen <keld\@dkuug.dk> 40*0Sstevel@tonic-gateCC: Andr\xE9 Pirard <PIRARD\@vm1.ulg.ac.be> 41*0Sstevel@tonic-gateSubject: If you can read this you understand the example. 42*0Sstevel@tonic-gateEOS 43*0Sstevel@tonic-gate 44*0Sstevel@tonic-gateis(Encode::decode('MIME-Header', $eheader), $dheader, "decode ASCII (RFC2047)"); 45*0Sstevel@tonic-gate 46*0Sstevel@tonic-gateuse utf8; 47*0Sstevel@tonic-gate 48*0Sstevel@tonic-gatemy $uheader =<<'EOS'; 49*0Sstevel@tonic-gateFrom: =?US-ASCII?Q?Keith_Moore?= <moore@cs.utk.edu> 50*0Sstevel@tonic-gateTo: =?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?= <keld@dkuug.dk> 51*0Sstevel@tonic-gateCC: =?ISO-8859-1?Q?Andr=E9?= Pirard <PIRARD@vm1.ulg.ac.be> 52*0Sstevel@tonic-gateSubject: =?ISO-8859-1?B?SWYgeW91IGNhbiByZWFkIHRoaXMgeW8=?= 53*0Sstevel@tonic-gate =?ISO-8859-2?B?dSB1bmRlcnN0YW5kIHRoZSBleGFtcGxlLg==?= 54*0Sstevel@tonic-gateEOS 55*0Sstevel@tonic-gate 56*0Sstevel@tonic-gateis(Encode::decode('MIME-Header', $uheader), $dheader, "decode UTF-8 (RFC2047)"); 57*0Sstevel@tonic-gate 58*0Sstevel@tonic-gate 59*0Sstevel@tonic-gate$dheader=<<'EOS'; 60*0Sstevel@tonic-gateFrom: 小飼 弾 <dankogai@dan.co.jp> 61*0Sstevel@tonic-gateTo: dankogai@dan.co.jp (小飼=Kogai, 弾=Dan) 62*0Sstevel@tonic-gateSubject: 漢字、カタカナ、ひらがなを含む、非常に長いタイトル行が一体全体どのようにしてEncodeされるのか? 63*0Sstevel@tonic-gateEOS 64*0Sstevel@tonic-gate 65*0Sstevel@tonic-gatemy $bheader =<<'EOS'; 66*0Sstevel@tonic-gateFrom:=?UTF-8?B?IOWwj+mjvCDlvL4g?=<dankogai@dan.co.jp> 67*0Sstevel@tonic-gateTo: dankogai@dan.co.jp (=?UTF-8?B?5bCP6aO8?==Kogai,=?UTF-8?B?IOW8vg==?==Dan 68*0Sstevel@tonic-gate ) 69*0Sstevel@tonic-gateSubject: 70*0Sstevel@tonic-gate =?UTF-8?B?IOa8ouWtl+OAgeOCq+OCv+OCq+ODiuOAgeOBsuOCieOBjOOBquOCkuWQq+OCgA==?= 71*0Sstevel@tonic-gate =?UTF-8?B?44CB6Z2e5bi444Gr6ZW344GE44K/44Kk44OI44Or6KGM44GM5LiA5L2T5YWo?= 72*0Sstevel@tonic-gate =?UTF-8?B?5L2T44Gp44Gu44KI44GG44Gr44GX44GmRW5jb2Rl44GV44KM44KL44Gu44GL?= 73*0Sstevel@tonic-gate =?UTF-8?B?77yf?= 74*0Sstevel@tonic-gateEOS 75*0Sstevel@tonic-gate 76*0Sstevel@tonic-gatemy $qheader=<<'EOS'; 77*0Sstevel@tonic-gateFrom:=?UTF-8?Q?=20=E5=B0=8F=E9=A3=BC=20=E5=BC=BE=20?=<dankogai@dan.co.jp> 78*0Sstevel@tonic-gateTo: dankogai@dan.co.jp (=?UTF-8?Q?=E5=B0=8F=E9=A3=BC?==Kogai, 79*0Sstevel@tonic-gate =?UTF-8?Q?=20=E5=BC=BE?==Dan) 80*0Sstevel@tonic-gateSubject: 81*0Sstevel@tonic-gate =?UTF-8?Q?=20=E6=BC=A2=E5=AD=97=E3=80=81=E3=82=AB=E3=82=BF=E3=82=AB?= 82*0Sstevel@tonic-gate =?UTF-8?Q?=E3=83=8A=E3=80=81=E3=81=B2=E3=82=89=E3=81=8C=E3=81=AA=E3=82=92?= 83*0Sstevel@tonic-gate =?UTF-8?Q?=E5=90=AB=E3=82=80=E3=80=81=E9=9D=9E=E5=B8=B8=E3=81=AB=E9=95=B7?= 84*0Sstevel@tonic-gate =?UTF-8?Q?=E3=81=84=E3=82=BF=E3=82=A4=E3=83=88=E3=83=AB=E8=A1=8C=E3=81=8C?= 85*0Sstevel@tonic-gate =?UTF-8?Q?=E4=B8=80=E4=BD=93=E5=85=A8=E4=BD=93=E3=81=A9=E3=81=AE=E3=82=88?= 86*0Sstevel@tonic-gate =?UTF-8?Q?=E3=81=86=E3=81=AB=E3=81=97=E3=81=A6Encode=E3=81=95?= 87*0Sstevel@tonic-gate =?UTF-8?Q?=E3=82=8C=E3=82=8B=E3=81=AE=E3=81=8B=EF=BC=9F?= 88*0Sstevel@tonic-gateEOS 89*0Sstevel@tonic-gate 90*0Sstevel@tonic-gateis(Encode::decode('MIME-Header', $bheader), $dheader, "decode B"); 91*0Sstevel@tonic-gateis(Encode::decode('MIME-Header', $qheader), $dheader, "decode Q"); 92*0Sstevel@tonic-gateis(Encode::encode('MIME-B', $dheader)."\n", $bheader, "encode B"); 93*0Sstevel@tonic-gateis(Encode::encode('MIME-Q', $dheader)."\n", $qheader, "encode Q"); 94*0Sstevel@tonic-gate 95*0Sstevel@tonic-gate$dheader = "What is =?UTF-8?B?w4RwZmVs?= ?"; 96*0Sstevel@tonic-gate$bheader = "What is =?UTF-8?B?PT9VVEYtOD9CP3c0UndabVZzPz0=?= ?"; 97*0Sstevel@tonic-gate$qheader = "What is =?UTF-8?Q?=3D=3FUTF=2D8=3FB=3Fw4RwZmVs=3F=3D?= ?"; 98*0Sstevel@tonic-gateis(Encode::encode('MIME-B', $dheader), $bheader, "Double decode B"); 99*0Sstevel@tonic-gateis(Encode::encode('MIME-Q', $dheader), $qheader, "Double decode Q"); 100*0Sstevel@tonic-gate{ 101*0Sstevel@tonic-gate # From: Dave Evans <dave@rudolf.org.uk> 102*0Sstevel@tonic-gate # Subject: Bug in Encode::MIME::Header 103*0Sstevel@tonic-gate # Message-Id: <3F43440B.7060606@rudolf.org.uk> 104*0Sstevel@tonic-gate use charnames ":full"; 105*0Sstevel@tonic-gate my $pound_1024 = "\N{POUND SIGN}1024"; 106*0Sstevel@tonic-gate is(Encode::encode('MIME-Q' => $pound_1024), '=?UTF-8?Q?=C2=A31024?=', 107*0Sstevel@tonic-gate 'pound 1024'); 108*0Sstevel@tonic-gate} 109*0Sstevel@tonic-gate__END__; 110