OSDN Git Service

91a9af882d710f6804bebf57ef3f73399bb8aafd
[nkf/nkf.git] / nkf_test.pl
1 #!/usr/local/bin/perl
2 #
3 # nkf test program for nkf-2
4 #
5 #    Shinji KONO <kono@ie.u-ryukyu.ac.jp>
6 # Sun Aug 18 12:25:40 JST 1996
7 # Sun Nov  8 00:16:06 JST 1998
8 #
9 # This is useful when you add new patch on nkf.
10 # Since this test is too strict, faileurs may not mean
11 # wrong conversion. 
12 #
13 # nkf 1.5 differs on MIME decoding
14 # nkf 1.4 passes Basic Conversion tests
15 # nkf PDS version passes Basic Conversion tests  using "nkf -iB -oB "
16 #
17
18 # Basic Conversion
19 print "\nBasic Conversion test\n\n";
20
21 # I gave up simple literal quote because there are big difference
22 # on perl4 and perl5 on literal quote. Of course we cannot use
23 # jperl.
24
25 $example{'jis'} = unpack('u',<<'eofeof');
26 M1FER<W0@4W1A9V4@&R1"(3DQ(3%^2R%+?D]3&RA"(%-E8V]N9"!3=&%G92`;
27 M)$)0)TU:&RA"($AI<F%G86YA(!LD0B0B)"0D)B0H)"HD;R1R)',;*$(*2V%T
28 M86MA;F$@&R1")2(E)"4F)2@E*B5O)7(E<QLH0B!+:6=O=2`;)$(A)B%G(S`C
29 /029!)E@G(B=!*$`;*$(*
30 eofeof
31
32 $example{'sjis'} = unpack('u',<<'eofeof');
33 M1FER<W0@4W1A9V4@@5B)0(F>ED"6GIAR(%-E8V]N9"!3=&%G92"8I9=Y($AI
34 M<F%G86YA((*@@J*"I(*F@JB"[8+P@O$*2V%T86MA;F$@@T&#0X-%@T>#28./
35 >@Y*#DR!+:6=O=2"!18&'@D^"8(._@]:$081@A+X*
36 eofeof
37
38 $example{'euc'} = unpack('u',<<'eofeof');
39 M1FER<W0@4W1A9V4@H;FQH;'^RZ'+_L_3(%-E8V]N9"!3=&%G92#0I\W:($AI
40 M<F%G86YA(*2BI*2DIJ2HI*JD[Z3RI/,*2V%T86MA;F$@I:*EI*6FI:BEJJ7O
41 >I?*E\R!+:6=O=2"AIJ'GH["CP:;!IMBGHJ?!J,`*
42 eofeof
43
44 $example{'utf8'} = unpack('u',<<'eofeof');
45 M[[N_1FER<W0@4W1A9V4@XX"%Z9FBY;^<YK.5YKJ`Z(65(%-E8V]N9"!3=&%G
46 M92#DN+SI@:4@2&ER86=A;F$@XX&"XX&$XX&&XX&(XX&*XX*/XX*2XX*3"DMA
47 M=&%K86YA(.."HN."I.."IN."J.."JN.#K^.#LN.#LR!+:6=O=2#C@[OBB)[O
48 1O)#OO*'.L<^)T)'0K^*5@@H`
49 eofeof
50
51 $example{'utf8N'} = unpack('u',<<'eofeof');
52 M1FER<W0@4W1A9V4@XX"%Z9FBY;^<YK.5YKJ`Z(65(%-E8V]N9"!3=&%G92#D
53 MN+SI@:4@2&ER86=A;F$@XX&"XX&$XX&&XX&(XX&*XX*/XX*2XX*3"DMA=&%K
54 M86YA(.."HN."I.."IN."J.."JN.#K^.#LN.#LR!+:6=O=2#C@[OBB)[OO)#O
55 .O*'.L<^)T)'0K^*5@@H`
56 eofeof
57
58 $example{'u16L'} = unpack('u',<<'eofeof');
59 M__Y&`&D`<@!S`'0`(`!3`'0`80!G`&4`(``%,&*6W%_5;(!N58$@`%,`90!C
60 M`&\`;@!D`"``4P!T`&$`9P!E`"``/$YED"``2`!I`'(`80!G`&$`;@!A`"``
61 M0C!$,$8P2#!*,(\PDC"3,`H`2P!A`'0`80!K`&$`;@!A`"``HC"D,*8PJ#"J
62 I,.\P\C#S,"``2P!I`&<`;P!U`"``^S`>(A#_(?^Q`\D#$00O!$(E"@``
63 eofeof
64
65 $example{'u16L0'} = unpack('u',<<'eofeof');
66 M1@!I`'(`<P!T`"``4P!T`&$`9P!E`"``!3!BEMQ?U6R`;E6!(`!3`&4`8P!O
67 M`&X`9``@`%,`=`!A`&<`90`@`#Q.99`@`$@`:0!R`&$`9P!A`&X`80`@`$(P
68 M1#!&,$@P2C"/,)(PDS`*`$L`80!T`&$`:P!A`&X`80`@`*(PI#"F,*@PJC#O
69 G,/(P\S`@`$L`:0!G`&\`=0`@`/LP'B(0_R'_L0/)`Q$$+P1")0H`
70 eofeof
71
72 $example{'u16B'} = unpack('u',<<'eofeof');
73 M_O\`1@!I`'(`<P!T`"``4P!T`&$`9P!E`"`P!99B7]QLU6Z`@54`(`!3`&4`
74 M8P!O`&X`9``@`%,`=`!A`&<`90`@3CR090`@`$@`:0!R`&$`9P!A`&X`80`@
75 M,$(P1#!&,$@P2C"/,)(PDP`*`$L`80!T`&$`:P!A`&X`80`@,*(PI#"F,*@P
76 IJC#O,/(P\P`@`$L`:0!G`&\`=0`@,/LB'O\0_R$#L0/)!!$$+R5"``H`
77 eofeof
78
79 $example{'u16B0'} = unpack('u',<<'eofeof');
80 M`$8`:0!R`',`=``@`%,`=`!A`&<`90`@,`668E_<;-5N@(%5`"``4P!E`&,`
81 M;P!N`&0`(`!3`'0`80!G`&4`($X\D&4`(`!(`&D`<@!A`&<`80!N`&$`(#!"
82 M,$0P1C!(,$HPCS"2,),`"@!+`&$`=`!A`&L`80!N`&$`(#"B,*0PIC"H,*HP
83 G[S#R,/,`(`!+`&D`9P!O`'4`(##[(A[_$/\A`[$#R001!"\E0@`*
84 eofeof
85
86 $example{'jis1'} = unpack('u',<<'eofeof');
87 M&R1";3%Q<$$L&RA""ALD0F4Z3F\;*$(*&R1"<FT;*$()&R1"/F5.3D]+&RA"
88 #"0D*
89 eofeof
90
91 $example{'sjis1'} = unpack('u',<<'eofeof');
92 8YU#ID)%+"N-9E^T*Z>L)C^.7S)AJ"0D*
93 eofeof
94
95 $example{'euc1'} = unpack('u',<<'eofeof');
96 8[;'Q\,&L"N6ZSN\*\NT)ON7.SL_+"0D*
97 eofeof
98
99 $example{'utf1'} = unpack('u',<<'eofeof');
100 AZ+J%Z:N/Z8JM"N>VNNFZEPKIM(D)Y+B*Z:"8Y+J8"0D*
101 eofeof
102
103 $example{'jis2'} = unpack('u',<<'eofeof');
104 +&R1".EA&(QLH0@H`
105 eofeof
106
107 $example{'sjis2'} = unpack('u',<<'eofeof');
108 %C=:3H0H`
109 eofeof
110
111 $example{'euc2'} = unpack('u',<<'eofeof');
112 %NMC&HPH`
113 eofeof
114
115 $example{'utf2'} = unpack('u',<<'eofeof');
116 'YI:.Z)>D"@``
117 eofeof
118
119 # From JIS
120
121 print "JIS  to JIS ...";&test("$nkf -j",$example{'jis'},$example{'jis'});
122 print "JIS  to SJIS...";&test("$nkf -s",$example{'jis'},$example{'sjis'});
123 print "JIS  to EUC ...";&test("$nkf -e",$example{'jis'},$example{'euc'});
124 print "JIS  to UTF8...";&test("$nkf -w",$example{'jis'},$example{'utf8N'});
125 print "JIS  to U16L...";&test("$nkf -w16L",$example{'jis'},$example{'u16L'});
126 print "JIS  to U16B...";&test("$nkf -w16B",$example{'jis'},$example{'u16B'});
127 print "JIS  to JIS ...";&test("$nkf --ic=iso-2022-jp --oc=iso-2022-jp"  ,$example{'jis'},$example{'jis'});
128 print "JIS  to SJIS...";&test("$nkf --ic=iso-2022-jp --oc=shift_jis"    ,$example{'jis'},$example{'sjis'});
129 print "JIS  to EUC ...";&test("$nkf --ic=iso-2022-jp --oc=euc-jp"       ,$example{'jis'},$example{'euc'});
130 print "JIS  to UTF8...";&test("$nkf --ic=iso-2022-jp --oc=utf-8n"       ,$example{'jis'},$example{'utf8N'});
131 print "JIS  to U16L...";&test("$nkf --ic=iso-2022-jp --oc=utf-16le-bom",$example{'jis'},$example{'u16L'});
132 print "JIS  to U16B...";&test("$nkf --ic=iso-2022-jp --oc=utf-16be-bom",$example{'jis'},$example{'u16B'});
133
134 # From SJIS
135
136 print "SJIS to JIS ...";&test("$nkf -j",$example{'sjis'},$example{'jis'});
137 print "SJIS to SJIS...";&test("$nkf -s",$example{'sjis'},$example{'sjis'});
138 print "SJIS to EUC ...";&test("$nkf -e",$example{'sjis'},$example{'euc'});
139 print "SJIS to UTF8...";&test("$nkf -w",$example{'sjis'},$example{'utf8N'});
140 print "SJIS to U16L...";&test("$nkf -w16L",$example{'sjis'},$example{'u16L'});
141 print "SJIS to U16B...";&test("$nkf -w16B",$example{'sjis'},$example{'u16B'});
142 print "SJIS to JIS ...";&test("$nkf --ic=shift_jis --oc=iso-2022-jp"    ,$example{'sjis'},$example{'jis'});
143 print "SJIS to SJIS...";&test("$nkf --ic=shift_jis --oc=shift_jis"      ,$example{'sjis'},$example{'sjis'});
144 print "SJIS to EUC ...";&test("$nkf --ic=shift_jis --oc=euc-jp" ,$example{'sjis'},$example{'euc'});
145 print "SJIS to UTF8...";&test("$nkf --ic=shift_jis --oc=utf-8n" ,$example{'sjis'},$example{'utf8N'});
146 print "SJIS to U16L...";&test("$nkf --ic=shift_jis --oc=utf-16le-bom"   ,$example{'sjis'},$example{'u16L'});
147 print "SJIS to U16B...";&test("$nkf --ic=shift_jis --oc=utf-16be-bom"   ,$example{'sjis'},$example{'u16B'});
148
149 # From EUC
150
151 print "EUC  to JIS ...";&test("$nkf -j",$example{'euc'},$example{'jis'});
152 print "EUC  to SJIS...";&test("$nkf -s",$example{'euc'},$example{'sjis'});
153 print "EUC  to EUC ...";&test("$nkf -e",$example{'euc'},$example{'euc'});
154 print "EUC  to UTF8...";&test("$nkf -w",$example{'euc'},$example{'utf8N'});
155 print "EUC  to U16L...";&test("$nkf -w16L",$example{'euc'},$example{'u16L'});
156 print "EUC  to U16B...";&test("$nkf -w16B",$example{'euc'},$example{'u16B'});
157 print "EUC  to JIS ...";&test("$nkf --ic=euc-jp --oc=iso-2022-jp"       ,$example{'euc'},$example{'jis'});
158 print "EUC  to SJIS...";&test("$nkf --ic=euc-jp --oc=shift_jis" ,$example{'euc'},$example{'sjis'});
159 print "EUC  to EUC ...";&test("$nkf --ic=euc-jp --oc=euc-jp"    ,$example{'euc'},$example{'euc'});
160 print "EUC  to UTF8...";&test("$nkf --ic=euc-jp --oc=utf-8n"    ,$example{'euc'},$example{'utf8N'});
161 print "EUC  to U16L...";&test("$nkf --ic=euc-jp --oc=utf-16le-bom"      ,$example{'euc'},$example{'u16L'});
162 print "EUC  to U16B...";&test("$nkf --ic=euc-jp --oc=utf-16be-bom"      ,$example{'euc'},$example{'u16B'});
163
164 # From UTF8
165
166 print "UTF8 to JIS ...";&test("$nkf -j",        $example{'utf8N'},$example{'jis'});
167 print "UTF8 to SJIS...";&test("$nkf -s",        $example{'utf8N'},$example{'sjis'});
168 print "UTF8 to EUC ...";&test("$nkf -e",        $example{'utf8N'},$example{'euc'});
169 print "UTF8 to UTF8N..";&test("$nkf -w",        $example{'utf8N'},$example{'utf8N'});
170 print "UTF8 to UTF8...";&test("$nkf -w8",       $example{'utf8N'},$example{'utf8'});
171 print "UTF8 to UTF8N..";&test("$nkf -w80",      $example{'utf8N'},$example{'utf8N'});
172 print "UTF8 to U16L...";&test("$nkf -w16L",     $example{'utf8N'},$example{'u16L'});
173 print "UTF8 to U16L0..";&test("$nkf -w16L0",    $example{'utf8N'},$example{'u16L0'});
174 print "UTF8 to U16B...";&test("$nkf -w16B",     $example{'utf8N'},$example{'u16B'});
175 print "UTF8 to U16B0..";&test("$nkf -w16B0",    $example{'utf8N'},$example{'u16B0'});
176 print "UTF8 to JIS ...";&test("$nkf --ic=utf-8 --oc=iso-2022-jp",       $example{'utf8N'},$example{'jis'});
177 print "UTF8 to SJIS...";&test("$nkf --ic=utf-8 --oc=shift_jis", $example{'utf8N'},$example{'sjis'});
178 print "UTF8 to EUC ...";&test("$nkf --ic=utf-8 --oc=euc-jp",            $example{'utf8N'},$example{'euc'});
179 print "UTF8 to UTF8N..";&test("$nkf --ic=utf-8 --oc=utf-8",             $example{'utf8N'},$example{'utf8N'});
180 print "UTF8 to UTF8BOM";&test("$nkf --ic=utf-8 --oc=utf-8-bom", $example{'utf8N'},$example{'utf8'});
181 print "UTF8 to UTF8N..";&test("$nkf --ic=utf-8 --oc=utf-8n",            $example{'utf8N'},$example{'utf8N'});
182 print "UTF8 to U16L...";&test("$nkf --ic=utf-8 --oc=utf-16le-bom",      $example{'utf8N'},$example{'u16L'});
183 print "UTF8 to U16L0..";&test("$nkf --ic=utf-8 --oc=utf-16le",          $example{'utf8N'},$example{'u16L0'});
184 print "UTF8 to U16B...";&test("$nkf --ic=utf-8 --oc=utf-16be-bom",      $example{'utf8N'},$example{'u16B'});
185 print "UTF8 to U16B0..";&test("$nkf --ic=utf-8 --oc=utf-16be",          $example{'utf8N'},$example{'u16B0'});
186
187 print "UTF8 to UTF8...";&test("$nkf -w","\xf0\xa0\x80\x8b","\xf0\xa0\x80\x8b");
188
189 # From JIS
190
191 print "JIS  to JIS ...";&test("$nkf -j",$example{'jis1'},$example{'jis1'});
192 print "JIS  to SJIS...";&test("$nkf -s",$example{'jis1'},$example{'sjis1'});
193 print "JIS  to EUC ...";&test("$nkf -e",$example{'jis1'},$example{'euc1'});
194 print "JIS  to UTF8...";&test("$nkf -w",$example{'jis1'},$example{'utf1'});
195
196 # From SJIS
197
198 print "SJIS to JIS ...";&test("$nkf -j",$example{'sjis1'},$example{'jis1'});
199 print "SJIS to SJIS...";&test("$nkf -s",$example{'sjis1'},$example{'sjis1'});
200 print "SJIS to EUC ...";&test("$nkf -e",$example{'sjis1'},$example{'euc1'});
201 print "SJIS to UTF8...";&test("$nkf -w",$example{'sjis1'},$example{'utf1'});
202
203 # From EUC
204
205 print "EUC  to JIS ...";&test("$nkf -j",$example{'euc1'},$example{'jis1'});
206 print "EUC  to SJIS...";&test("$nkf -s",$example{'euc1'},$example{'sjis1'});
207 print "EUC  to EUC ...";&test("$nkf -e",$example{'euc1'},$example{'euc1'});
208 print "EUC  to UTF8...";&test("$nkf -w",$example{'euc1'},$example{'utf1'});
209
210 # From UTF8
211
212 print "UTF8 to JIS ...";&test("$nkf -j",$example{'utf1'},$example{'jis1'});
213 print "UTF8 to SJIS...";&test("$nkf -s",$example{'utf1'},$example{'sjis1'});
214 print "UTF8 to EUC ...";&test("$nkf -e",$example{'utf1'},$example{'euc1'});
215 print "UTF8 to UTF8...";&test("$nkf -w",$example{'utf1'},$example{'utf1'});
216
217 # UTF
218 sub h {pack("H*",shift)}
219 print "SJIS to -w...          ";&test("$nkf -w",h("82A0"),h("E38182"));
220 print "SJIS to -w8...         ";&test("$nkf -w8",h("82A0"),h("EFBBBFE38182"));
221 print "SJIS to -w80...        ";&test("$nkf -w80",h("82A0"),h("E38182"));
222 print "SJIS to UTF-8...       ";&test("$nkf --oc=UTF-8",h("82A0"),h("E38182"));
223 print "SJIS to UTF-8N...      ";&test("$nkf --oc=UTF-8N",h("82A0"),h("E38182"));
224 print "SJIS to UTF-8-BOM...   ";&test("$nkf --oc=UTF-8-BOM",h("82A0"),h("EFBBBFE38182"));
225 print "SJIS to -w16...        ";&test("$nkf -w16",h("82A0"),h("FEFF3042"));
226 print "SJIS to UTF-16...      ";&test("$nkf --oc=UTF-16",h("82A0"),h("FEFF3042"));
227 print "SJIS to -w16B...       ";&test("$nkf -w16B",h("82A0"),h("FEFF3042"));
228 print "SJIS to -w16B0...      ";&test("$nkf -w16B0",h("82A0"),h("3042"));
229 print "SJIS to UTF-16BE...    ";&test("$nkf --oc=UTF-16BE",h("82A0"),h("3042"));
230 print "SJIS to UTF-16BE-BOM...";&test("$nkf --oc=UTF-16BE-BOM",h("82A0"),h("FEFF3042"));
231 print "SJIS to -w16L...       ";&test("$nkf -w16L",h("82A0"),h("FFFE4230"));
232 print "SJIS to -w16L0...      ";&test("$nkf -w16L0",h("82A0"),h("4230"));
233 print "SJIS to UTF-16LE...    ";&test("$nkf --oc=UTF-16LE",h("82A0"),h("4230"));
234 print "SJIS to UTF-16LE-BOM...";&test("$nkf --oc=UTF-16LE-BOM",h("82A0"),h("FFFE4230"));
235 print "SJIS to -w32...        ";&test("$nkf -w32",h("82A0"),h("0000FEFF00003042"));
236 print "SJIS to UTF-32...      ";&test("$nkf --oc=UTF-32",h("82A0"),h("0000FEFF00003042"));
237 print "SJIS to -w32B...       ";&test("$nkf -w32B",h("82A0"),h("0000FEFF00003042"));
238 print "SJIS to -w32B0...      ";&test("$nkf -w32B0",h("82A0"),h("00003042"));
239 print "SJIS to UTF-32BE...    ";&test("$nkf --oc=UTF-32BE",h("82A0"),h("00003042"));
240 print "SJIS to UTF-32BE-BOM...";&test("$nkf --oc=UTF-32BE-BOM",h("82A0"),h("0000FEFF00003042"));
241 print "SJIS to -w32L...       ";&test("$nkf -w32L",h("82A0"),h("FFFE000042300000"));
242 print "SJIS to -w32L0...      ";&test("$nkf -w32L0",h("82A0"),h("42300000"));
243 print "SJIS to UTF-32LE...    ";&test("$nkf --oc=UTF-32LE",h("82A0"),h("42300000"));
244 print "SJIS to UTF-32LE-BOM...";&test("$nkf --oc=UTF-32LE-BOM",h("82A0"),h("FFFE000042300000"));
245
246
247 print "\nOther Features\n\n";
248 # Ambigous Case
249
250 $example{'amb'} = unpack('u',<<'eofeof');
251 MI<*PL:7"L+&EPK"QI<*PL:7"L+&EPK"QI<*PL:7"L+&EPK"QI<*PL:7"L+&E
252 MPK"QI<*PL:7"L+&EPK"QI<(*I<*PL:7"L+&EPK"QI<*PL:7"L+&EPK"QI<*P
253 ML:7"L+&EPK"QI<*PL:7"L+&EPK"QI<*PL:7"L+&EPK"QI<(*I<*PL:7"L+&E
254 MPK"QI<*PL:7"L+&EPK"QI<*PL:7"L+&EPK"QI<*PL:7"L+&EPK"QI<*PL:7"
255 ML+&EPK"QI<(*I<*PL:7"L+&EPK"QI<*PL:7"L+&EPK"QI<*PL:7"L+&EPK"Q
256 MI<*PL:7"L+&EPK"QI<*PL:7"L+&EPK"QI<(*I<*PL:7"L+&EPK"QI<*PL:7"
257 ML+&EPK"QI<*PL:7"L+&EPK"QI<*PL:7"L+&EPK"QI<*PL:7"L+&EPK"QI<(*
258 eofeof
259
260 $example{'amb.euc'} = unpack('u',<<'eofeof');
261 M&R1")4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(P,25"
262 M,#$E0C`Q)4(P,25",#$E0C`Q)4(;*$(*&R1")4(P,25",#$E0C`Q)4(P,25"
263 M,#$E0C`Q)4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(;
264 M*$(*&R1")4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(P
265 M,25",#$E0C`Q)4(P,25",#$E0C`Q)4(;*$(*&R1")4(P,25",#$E0C`Q)4(P
266 M,25",#$E0C`Q)4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(P,25",#$E0C`Q
267 M)4(;*$(*&R1")4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(P,25",#$E0C`Q
268 >)4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(;*$(*
269 eofeof
270
271 $example{'amb.sjis'} = unpack('u',<<'eofeof');
272 M&RA))4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(P,25"
273 M,#$E0C`Q)4(P,25",#$E0C`Q)4(;*$(*&RA))4(P,25",#$E0C`Q)4(P,25"
274 M,#$E0C`Q)4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(;
275 M*$(*&RA))4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(P
276 M,25",#$E0C`Q)4(P,25",#$E0C`Q)4(;*$(*&RA))4(P,25",#$E0C`Q)4(P
277 M,25",#$E0C`Q)4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(P,25",#$E0C`Q
278 M)4(;*$(*&RA))4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(P,25",#$E0C`Q
279 >)4(P,25",#$E0C`Q)4(P,25",#$E0C`Q)4(;*$(*
280 eofeof
281
282 printf "%-40s", "Ambiguous Case.";
283     &test("$nkf -j",$example{'amb'},$example{'amb.euc'});
284
285 # Input assumption
286
287 printf "%-40s", "SJIS  Input assumption";
288     &test("$nkf -jSx",$example{'amb'},$example{'amb.sjis'});
289
290 # UTF8_STR_OF_JIS_SECOND_LEVEL_KANJI
291 $example{'utf8_str_of_jis_second_level_kanji'} = "\xe9\xa4\x83\xe5\xad\x90";
292
293 printf "%-40s", "UTF8_STR_OF_JIS_SECOND_LEVEL_KANJI";
294     &test("$nkf -w",$example{'utf8_str_of_jis_second_level_kanji'},
295             $example{'utf8_str_of_jis_second_level_kanji'});
296
297 # Broken JIS
298
299 printf "%-40s", "Broken JIS";
300     $input = $example{'jis'};
301     $input =~ s/\033//g;
302     &test("$nkf -Be",$input,$example{'euc'});
303 printf "%-40s", "Broken JIS is safe on Normal JIS?";
304     $input = $example{'jis'};
305     &test("$nkf -Be",$input,$example{'euc'});
306
307 # test_data/cp932
308
309 $example{'test_data/cp932'} = unpack('u',<<'eofeof');
310 %^D`@_$L`
311 eofeof
312
313 $example{'test_data/cp932.ans'} = unpack('u',<<'eofeof');
314 %_/$@_.X`
315 eofeof
316
317 printf "%-40s", "test_data/cp932";
318     &test("$nkf -eS",$example{'test_data/cp932'},$example{'test_data/cp932.ans'});
319 printf "%-40s", "test_data/cp51932";
320     &test("$nkf --ic=cp932 --oc=cp51932",$example{'test_data/cp932'},$example{'test_data/cp932.ans'});
321
322 # test_data/cp932inv
323 printf "%-40s", "test_data/cp932inv";
324     &test("$nkf -sE --cp932",$example{'test_data/cp932.ans'},$example{'test_data/cp932'});
325
326 # test_data/no-cp932inv
327
328 $example{'test_data/no-cp932inv.ans'} = unpack('u',<<'eofeof');
329 %[N\@[NP`
330 eofeof
331
332 printf "%-40s", "test_data/no-cp932inv";
333     &test("$nkf -sE --no-cp932",$example{'test_data/cp932.ans'},$example{'test_data/no-cp932inv.ans'});
334 # JIS X 0212
335 $example{'jisx0212_euc'} = "\x8F\xA2\xAF\x8F\xED\xE3";
336 $example{'jisx0212_jis'} = "\x1b\x24\x28\x44\x22\x2f\x6d\x63\x1b\x28\x42";
337
338 printf "%-40s", "ISO-2022-JP-1 to EUC-JP";
339     &test("$nkf --ic=ISO-2022-JP-1 --oc=EUC-JP",$example{'jisx0212_jis'},$example{'jisx0212_euc'});
340
341 printf "%-40s", "EUC-JP to ISO-2022-JP-1";
342     &test("$nkf --ic=EUC-JP --oc=ISO-2022-JP-1",$example{'jisx0212_euc'},$example{'jisx0212_jis'});
343 # JIS X 0213
344
345 $example{'jisx0213_sjis'} = unpack('u',<<'eofeof');
346 0@:V(G9ATF)WJIN_W\$#\]```
347 eofeof
348
349 $example{'jisx0213_euc'} = unpack('u',<<'eofeof');
350 2HJ^O_<_5S_WTJ/[YCZ&AC_[V
351 eofeof
352
353 $example{'jisx0213_jis2000'} = unpack('u',<<'eofeof');
354 ;&R0H3R(O+WU/54]]="A^>1LD*%`A(7YV&RA"
355 eofeof
356 $example{'jisx0213_jis2004'} = unpack('u',<<'eofeof');
357 ;&R0H42(O+WU/54]]="A^>1LD*%`A(7YV&RA"
358 eofeof
359
360 printf "%-40s", "Shift_JISX0213 to EUC-JISX0213";
361     &test("$nkf --ic=Shift_JISX0213 --oc=EUC-JISX0213",$example{'jisx0213_sjis'},$example{'jisx0213_euc'});
362
363 printf "%-40s", "EUC-JISX0213 to Shift_JISX0213";
364     &test("$nkf --ic=EUC-JISX0213 --oc=Shift_JISX0213",$example{'jisx0213_euc'},$example{'jisx0213_sjis'});
365
366 printf "%-40s", "ISO-2022-JP-3 to EUC-JISX0213";
367     &test("$nkf --ic=ISO-2022-JP-3 --oc=EUC-JISX0213",$example{'jisx0213_jis2000'},$example{'jisx0213_euc'});
368
369 printf "%-40s", "ISO-2022-JP-2004 to EUC-JISX0213";
370     &test("$nkf --ic=ISO-2022-JP-2004 --oc=EUC-JISX0213",$example{'jisx0213_jis2004'},$example{'jisx0213_euc'});
371
372 printf "%-40s", "EUC-JISX0213 to ISO-2022-JP-2004";
373     &test("$nkf --ic=EUC-JISX0213 --oc=ISO-2022-JP-2004",$example{'jisx0213_euc'},$example{'jisx0213_jis2004'});
374 # test_data/no_best_fit_chars
375
376 $example{'test_data/no_best_fit_chars'} = unpack('u',<<'eofeof');
377 ;XH"5XHBE[[R-[[^@[[^A[[^B[[^C[[^D[[^E
378 eofeof
379
380 printf "%-40s", "no_best_fit_chars (eucJP-ascii)";
381     &test("$nkf -W --oc=eucJP-ascii --no-best-fit-chars",$example{'test_data/no_best_fit_chars'},'');
382
383 $example{'test_data/no_best_fit_chars_ms'} = unpack('u',<<'eofeof');
384 9PJ+"H\*EPJ;"K.*`E.*`EN*`ON*(DN.`G```
385 eofeof
386
387 printf "%-40s", "no_best_fit_chars (eucJP-ms)";
388     &test("$nkf -W --oc=eucJP-ms --no-best-fit-chars",$example{'test_data/no_best_fit_chars_ms'},'');
389
390 $example{'test_data/no_best_fit_chars_cp932'} = unpack('u',<<'eofeof');
391 MPJ'"HL*CPJ7"IL*IPJK"J\*LPJW"KL*OPK+"L\*UPK?"N,*YPKK"N\.`PX'#
392 M@L.#PX3#A<.&PX?#B,.)PXK#B\.,PXW#CL./PY##D<.2PY/#E,.5PY;#F,.9
393 MPYK#F\.<PYW#GL.?PZ##H<.BPZ/#I,.EPZ;#I\.HPZG#JL.KPZS#K<.NPZ_#
394 @L,.QP[+#L\.TP[7#ML.XP[G#NL.[P[S#O<.^P[_C@I0`
395 eofeof
396
397 printf "%-40s", "no_best_fit_chars (cp932)";
398     &test("$nkf -W --oc=CP932 --no-best-fit-chars",$example{'test_data/no_best_fit_chars_cp932'},'');
399 # test_data/irv
400
401 # $example{'test_data/irv'} = unpack('u',<<'eofeof');
402 # %#B`/(!L`
403 # eofeof
404
405 # $example{'test_data/irv.ans'} = unpack('u',<<'eofeof');
406 # %#B`/(!L`
407 # eofeof
408
409 # printf "%-40s", "test_data/irv";
410 #    &test("$nkf -wE",$example{'test_data/irv'},$example{'test_data/irv.ans'});
411
412
413 # UCS Mapping Test
414 print "\nUCS Mapping Test\n\n";
415
416 print "Shift_JIS to UTF-16\n";
417 $example{'ms_ucs_map_1_sjis'} = "\x81\x60\x81\x61\x81\x7C\x81\x91\x81\x92\x81\xCA";
418 $example{'ms_ucs_map_1_utf16'} = "\x30\x1C\x20\x16\x22\x12\x00\xA2\x00\xA3\x00\xAC";
419 $example{'ms_ucs_map_1_utf16_ms'} = "\xFF\x5E\x22\x25\xFF\x0D\xFF\xE0\xFF\xE1\xFF\xE2";
420
421 printf "%-40s", "Normal UCS Mapping :";
422     &test("$nkf -w16B0 --ic=Shift_JIS",$example{'ms_ucs_map_1_sjis'},$example{'ms_ucs_map_1_utf16'});
423
424 printf "%-40s", "Microsoft UCS Mapping :";
425     &test("$nkf -w16B0 -S --ms-ucs-map",$example{'ms_ucs_map_1_sjis'},$example{'ms_ucs_map_1_utf16_ms'});
426 printf "%-40s", "CP932 to UTF-16BE :";
427     &test("$nkf --ic=cp932 --oc=utf-16be",$example{'ms_ucs_map_1_sjis'},$example{'ms_ucs_map_1_utf16_ms'});
428
429 # X0201 仮名
430 # X0201->X0208 conversion
431 # X0208 aphabet -> ASCII
432 # X0201 相互変換
433
434 print "\nX0201 test\n\n";
435
436 $example{'x0201.sjis'} = unpack('u',<<'eofeof');
437 MD5.*<(-*@TR#3H-0@U*#2X--@T^#48-3"I%3B7""8()A@F*"8X)D@F6"9H*!
438 M@H*"@X*$@H6"AH*'"I%3BTR-AH%)@9>!E(&0@9.!3X&5@9:!:8%J@7R!>X&!
439 M@6V!;H%O@7"!CPJ4O(IPMK>X/;FZMMZWWKC>N=ZZWH+&"I2\BG#*W\O?S-_-
440 MW\[?M]^QW@K*W\O?S`IH86YK86MU(,K?R]_,I`K*W\O?S-VA"I2\BG""S(SC
441 !"@!"
442 eofeof
443
444 $example{'x0201.euc'} = unpack('u',<<'eofeof');
445 MP;2ST:6KI:VEKZ6QI;.EK*6NI;"ELJ6T"L&TL=&CP:/"H\.CQ*/%H\:CQZ/A
446 MH^*CXZ/DH^6CYJ/G"L&TM:VYYJ&JH?>A]*'PH?.AL*'UH?:ARJ'+H=VAW*'A
447 MH<ZASZ'0H=&A[PK(OK/1CK:.MXZX/8ZYCKJ.MH[>CK>.WHZXCMZ.N8[>CKJ.
448 MWJ3("LB^L]&.RH[?CLN.WX[,CM^.S8[?CLZ.WXZWCM^.L8[>"H[*CM^.RX[?
449 MCLP*:&%N:V%K=2".RH[?CLN.WX[,CJ0*CLJ.WX[+CM^.S([=CJ$*R+ZST:3.
450 #N.4*
451 eofeof
452
453 $example{'x0201.utf'} = unpack('u',<<'eofeof');
454 MY86HZ*>2XX*KXX*MXX*OXX*QXX*SXX*LXX*NXX*PXX*RXX*T"N6%J.B+L>^\
455 MH>^\HN^\H^^\I.^\I>^\IN^\I^^]@>^]@N^]@^^]A.^]A>^]AN^]APKEA:CH
456 MJ)CEC[?OO('OO*#OO(/OO(3OO(7OO+[OO(;OO(KOO(COO(GBB)+OO(OOO)WO
457 MO+OOO+WOO9OOO9W"I0KEC8KHIY+OO;;OO;?OO;@][[VY[[VZ[[VV[[Z>[[VW
458 M[[Z>[[VX[[Z>[[VY[[Z>[[VZ[[Z>XX&H"N6-BNBGDN^^BN^^G^^^B^^^G^^^
459 MC.^^G^^^C>^^G^^^CN^^G^^]M^^^G^^]L>^^G@KOOHKOOI_OOHOOOI_OOHP*
460 M:&%N:V%K=2#OOHKOOI_OOHOOOI_OOHSOO:0*[[Z*[[Z?[[Z+[[Z?[[Z,[[Z=
461 1[[VA"N6-BNBGDN.!KN6^C`H`
462 eofeof
463
464 $example{'x0201.jis'} = unpack('u',<<'eofeof');
465 M&R1"030S424K)2TE+R4Q)3,E+"4N)3`E,B4T&RA""ALD0D$T,5$C02-"(T,C
466 M1"-%(T8C1R-A(V(C8R-D(V4C9B-G&RA""ALD0D$T-2TY9B$J(7<A="%P(7,A
467 M,"%U(78A2B%+(5TA7"%A(4XA3R%0(5$A;QLH0@H;)$)(/C-1&RA)-C<X&RA"
468 M/1LH23DZ-EXW7CA>.5XZ7ALD0B1(&RA""ALD0D@^,U$;*$E*7TM?3%]-7TY?
469 M-U\Q7ALH0@H;*$E*7TM?3!LH0@IH86YK86MU(!LH24I?2U],)!LH0@H;*$E*
470 97TM?3%TA&RA""ALD0D@^,U$D3CAE&RA""@``
471 eofeof
472
473 $example{'x0201.sosi'} = unpack('u',<<'eofeof');
474 M&R1"030S424K)2TE+R4Q)3,E+"4N)3`E,B4T&RA*"ALD0D$T,5$C02-"(T,C
475 M1"-%(T8C1R-A(V(C8R-D(V4C9B-G&RA*"ALD0D$T-2TY9B$J(7<A="%P(7,A
476 M,"%U(78A2B%+(5TA7"%A(4XA3R%0(5$A;QLH2@H;)$)(/C-1&RA*#C8W.`\;
477 M*$H]#CDZ-EXW7CA>.5XZ7@\;)$(D2!LH2@H;)$)(/C-1&RA*#DI?2U],7TU?
478 M3E\W7S%>#PH.2E]+7TP/&RA*"FAA;FMA:W4@#DI?2U],)`\;*$H*#DI?2U],
479 672$/&RA*"ALD0D@^,U$D3CAE&RA""@``
480 eofeof
481
482 $example{'x0201.x0208'} = unpack('u',<<'eofeof');
483 M&R1"030S424K)2TE+R4Q)3,E+"4N)3`E,B4T&RA""ALD0D$T,5$;*$)!0D-$
484 M149'86)C9&5F9PH;)$)!-#4M.68;*$(A0",D)5XF*B@I+2L]6UU[?1LD0B%O
485 M&RA""ALD0D@^,U$E*R4M)2\;*$(]&R1")3$E,R4L)2XE,"4R)30D2!LH0@H;
486 M)$)(/C-1)5$E5"57)5HE724M(2PE(B$K&RA""ALD0B51)50E51LH0@IH86YK
487 M86MU(!LD0B51)50E52$B&RA""ALD0B51)50E525S(2,;*$(*&R1"2#XS421.
488 &.&4;*$(*
489 eofeof
490
491 # -X is necessary to allow X0201 in SJIS
492 # -Z convert X0208 alphabet to ASCII
493 printf "%-40s", "X0201 conversion: SJIS";
494     &test("$nkf -jXZ",$example{'x0201.sjis'},$example{'x0201.x0208'});
495 printf "%-40s", "X0201 conversion: JIS";
496     &test("$nkf -jZ",$example{'x0201.jis'},$example{'x0201.x0208'});
497 printf "%-40s", "X0201 conversion: SI/SO";
498     &test("$nkf -jZ",$example{'x0201.sosi'},$example{'x0201.x0208'});
499 printf "%-40s", "X0201 conversion: EUC";
500     &test("$nkf -jZ",$example{'x0201.euc'},$example{'x0201.x0208'});
501 printf "%-40s", "X0201 conversion: UTF8";
502     &test("$nkf -jZ",$example{'x0201.utf'},$example{'x0201.x0208'});
503 printf "%-40s", "-wZ"; &test("$nkf -wZ",
504         "\xE3\x80\x80\xEF\xBD\x81\xEF\xBC\xA1&\xE3\x82\xA2",
505         "\xE3\x80\x80aA&\xE3\x82\xA2");
506 printf "%-40s", "-wZ0"; &test("$nkf -wZ0",
507         "\xE3\x80\x80\xEF\xBD\x81\xEF\xBC\xA1&\xE3\x82\xA2",
508         "\xE3\x80\x80aA&\xE3\x82\xA2");
509 printf "%-40s", "-wZ1"; &test("$nkf -wZ1",
510         "\xE3\x80\x80\xEF\xBD\x81\xEF\xBC\xA1&\xE3\x82\xA2",
511         " aA&\xE3\x82\xA2");
512 printf "%-40s", "-wZ2"; &test("$nkf -wZ2",
513         "\xE3\x80\x80\xEF\xBD\x81\xEF\xBC\xA1&\xE3\x82\xA2",
514         "  aA&\xE3\x82\xA2");
515 printf "%-40s", "-wZ3"; &test("$nkf -wZ3",
516         "\xE3\x80\x80\xEF\xBD\x81\xEF\xBC\xA1&\xE3\x82\xA2",
517         "\xE3\x80\x80aA&amp;\xE3\x82\xA2");
518 printf "%-40s", "-wZ4"; &test("$nkf -wZ4",
519         "\xE3\x80\x80\xEF\xBD\x81\xEF\xBC\xA1&\xE3\x82\xA2",
520         "\xE3\x80\x80aA&\xEF\xBD\xB1");
521 # -x means X0201 output
522 printf "%-40s", "X0201 output: SJIS";
523     &test("$nkf -xs",$example{'x0201.euc'},$example{'x0201.sjis'});
524 printf "%-40s", "X0201 output: JIS";
525     &test("$nkf -xj",$example{'x0201.sjis'},$example{'x0201.jis'});
526 printf "%-40s", "X0201 output: EUC";
527     &test("$nkf -xe",$example{'x0201.jis'},$example{'x0201.euc'});
528 printf "%-40s", "X0201 output: UTF8";
529     &test("$nkf -xw",$example{'x0201.jis'},$example{'x0201.utf'});
530
531 # MIME decode
532
533 print "\nMIME test\n\n";
534
535 # MIME ISO-2022-JP
536
537 $example{'mime.iso2022'} = unpack('u',<<'eofeof');
538 M/3])4T\M,C`R,BU*4#]"/T=Y4D%.144W96E23TI566Q/4U9)1WEH2S\]"CT_
539 M:7-O+3(P,C(M2E`_0C]'>5)!3D5%-V5I4D]*55EL3U-624=Y:$L_/0H]/VES
540 M;RTR,#(R+4I0/U$_/3%")$(D1B11/3%"*$)?96YD/ST*&R1`)#TD)B0K)$H;
541 M*$H@/3])4T\M,C`R,BU*4#]"/T=Y4D%.144W96E23U!Y:S=D:'-O4V<]/3\]
542 M(&5N9"!O9B!L:6YE"CT_25-/+3(P,C(M2E`_0C]'>5)!3D5%-V5I4D]0>6LW
543 M9&AS;U-G/3T_/2`]/TE33RTR,#(R+4I0/T(_1WE204Y%13=E:5)/4'EK-V1H
544 M<V]39ST]/ST*0G)O:V5N(&-A<V4*/3])4T\M,C`R,BU*4#]"/T=Y4D%.144W
545 M96E23U!Y:S=D"FAS;U-G/3T_/2`]/TE33RTR,`HR,BU*4#]"/T=Y4D%.144W
546 M96E23U!Y:S=D:'-O4V<]/3\]"CT_25-/+3(P,C(M2E`_0C]'>5)!3D5%-V5I
547 44D]*55EL3QM;2U-624=Y:$L_/0H_
548 eofeof
549
550 $example{'mime.ans.strict'} = unpack('u',<<'eofeof');
551 M&R1"-$$[>B1.)48E.25(&RA""ALD0C1!.WHD3B5&)3DE2!LH0@H;)$(D1B11
552 M&RA"(&5N9`H;)$(D/20F)"LD2ALH0B`;)$(T03MZ)$X_*3MV&RA"96YD(&]F
553 M(&QI;F4*&R1"-$$[>B1./RD[=C1!.WHD3C\I.W8;*$(*0G)O:V5N(&-A<V4*
554 M/3])4T\M,C`R,BU*4#]"/T=Y4D%.144W96E23U!Y:S=D"FAS;U-G/3T_/2`]
555 M/TE33RTR,`HR,BU*4#]"/T=Y4D%.144W96E23U!Y:S=D:'-O4V<]/3\]"CT_
556 L25-/+3(P,C(M2E`_0C]'>5)!3D5%-V5I4D]*55EL3QM;2U-624=Y:$L_/0H_
557 eofeof
558
559 $example{'mime.unbuf.strict'} = unpack('u',<<'eofeof');
560 M&R1"-$$[>B1.)48E.25(&RA""ALD0C1!.WHD3B5&)3DE2!LH0@H;)$(D1B11
561 M&RA"(&5N9`H;)$(D/20F)"LD2ALH0B`;)$(T03MZ)$X_*3MV&RA"96YD(&]F
562 M(&QI;F4*&R1"-$$[>B1./RD[=C1!.WHD3C\I.W8;*$(*0G)O:V5N(&-A<V4*
563 M&R1"-$$[>B1./RD;*$)H<V]39ST]/ST@/3])4T\M,C`*,C(M2E`_0C]'>5)!
564 M3D5%-V5I4D]0>6LW9&AS;U-G/3T_/0H;)$(T03MZ)$XE1ALH0EM+4U9)1WEH
565 $2S\]"F5I
566 eofeof
567
568 $example{'mime.ans'} = unpack('u',<<'eofeof');
569 M&R1"-$$[>B1.)48E.25(&RA""ALD0C1!.WHD3B5&)3DE2!LH0@H;)$(D1B11
570 M&RA"(&5N9`H;)$(D/20F)"LD2ALH0B`;)$(T03MZ)$X_*3MV&RA"96YD(&]F
571 M(&QI;F4*&R1"-$$[>B1./RD[=C1!.WHD3C\I.W8;*$(*0G)O:V5N(&-A<V4*
572 M&R1"-$$[>B1./RD;*$)H<V]39ST]/ST@&R1"-$$[>B1./RD[=ALH0@H;)$(T
573 603MZ)$XE1ALH0EM+4U9)1WEH2S\]"@`*
574 eofeof
575
576 $example{'mime.unbuf'} = unpack('u',<<'eofeof');
577 M&R1"-$$[>B1.)48E.25(&RA""ALD0C1!.WHD3B5&)3DE2!LH0@H;)$(D1B11
578 M&RA"(&5N9`H;)$(D/20F)"LD2ALH0B`;)$(T03MZ)$X_*3MV&RA"96YD(&]F
579 M(&QI;F4*&R1"-$$[>B1./RD[=C1!.WHD3C\I.W8;*$(*0G)O:V5N(&-A<V4*
580 M&R1"-$$[>B1./RD;*$)H<V]39ST]/ST@&R1"-$$[>B1./RD[=ALH0@H;)$(T
581 603MZ)$XE1ALH0EM+4U9)1WEH2S\]"@`*
582 eofeof
583
584 $example{'mime.base64'} = unpack('u',<<'eofeof');
585 M9W-M5"])3&YG<FU#>$I+-&=Q=4,S24LS9W%Q0E%:3TUI-39,,S0Q-&=S5T)1
586 M43!+9VUA1%9O3T@*9S)+1%1O3'=K8C)1;$E+;V=Q2T-X24MG9W5M0W%*3EEG
587 <<T=#>$E+9V=U;4,X64Q&9W)70S592VMG<6U""F=Q
588 eofeof
589
590 $example{'mime.base64.ans'} = unpack('u',<<'eofeof');
591 M&R1")$M&?B1I)#LD1D0Z)"TD7B0Y)"PA(D5L-7XV83E9)$<A(ALH0@T*&R1"
592 M(T<E-R5G)4,E+R1R0C\_="0J)"0D1B0B)&LD*D4Y)$,D1B0B)&LD<R1')#<D
593 (9R0F)"L;*$(E
594 eofeof
595
596 # printf "%-40s", "Next test is expected to Fail.\n";
597 printf "%-40s", "MIME decode (strict)";
598     $tmp = &test("$nkf -jmS",$example{'mime.iso2022'},$example{'mime.ans.strict'});
599
600 $example{'mime.ans.alt'} = unpack('u',<<'eofeof');
601 M&R1"-$$[>B1.)48E.25(&RA""ALD0C1!.WHD3B5&)3DE2!LH0@H;)$(D1B11
602 M&RA"96YD"ALD0B0])"8D*R1*&RA"&R1"-$$[>B1./RD[=ALH0F5N9&]F;&EN
603 M90H;)$(T03MZ)$X_*3MV-$$[>B1./RD[=ALH0@I"<F]K96YC87-E"ALD0C1!
604 H.WHD3C\I.W8T03MZ)$X_*3MV&RA""ALD0C1!.WHD3B5&)3DE)!LH0@``
605 eofeof
606
607 $example{'mime.unbuf.alt'} = unpack('u',<<'eofeof');
608 M&R1"-$$[>B1.)48E.25(&RA""ALD0C1!.WHD3B5&)3DE2!LH0@H;)$(D1B11
609 M&RA"96YD"ALD0B0])"8D*R1*&RA"&R1"-$$[>B1./RD[=ALH0F5N9&]F;&EN
610 M90H;)$(T03MZ)$X_*3MV-$$[>B1./RD[=ALH0@I"<F]K96YC87-E"ALD0C1!
611 H.WHD3C\I.W8T03MZ)$X_*3MV&RA""ALD0C1!.WHD3B5&)3DE)!LH0@``
612 eofeof
613
614 printf "%-40s", "MIME decode (nonstrict)";
615     $tmp = &test("$nkf -jmN",$example{'mime.iso2022'},$example{'mime.ans'},$example{'mime.ans.alt'});
616     # open(OUT,">tmp1");printf "%-40s", OUT pack('u',$tmp);close(OUT);
617 # unbuf mode implies more pessimistic decode
618 printf "%-40s", "MIME decode (unbuf)";
619     $tmp = &test("$nkf -jmNu",$example{'mime.iso2022'},$example{'mime.unbuf'},$example{'mime.unbuf.alt'});
620     # open(OUT,">tmp2");printf "%-40s", OUT pack('u',$tmp);close(OUT);
621 printf "%-40s", "MIME decode (base64)";
622     &test("$nkf -jmB",$example{'mime.base64'},$example{'mime.base64.ans'});
623 #MIME BASE64 must be LF?
624
625 # MIME ISO-8859-1
626
627 $example{'mime.is8859'} = unpack('u',<<'eofeof');
628 M/3])4T\M.#@U.2TQ/U$_*CU#-V%V83\_/2`*4&5E<B!4]G)N9W)E;@I,87-S
629 M92!(:6QL97+X92!0971E<G-E;B`@7"`B36EN(&MA97!H97-T(&AA<B!F86%E
630 M="!E="!F;V5L(2(*06%R:'5S(%5N:79E<G-I='DL($1%3DU!4DL@(%P@(DUI
631 <;B!KYG!H97-T(&AA<B!FY65T(&5T(&;X;"$B"@!K
632 eofeof
633
634 $example{'mime.is8859.ans'} = unpack('u',<<'eofeof');
635 M*L=A=F$_(`I0965R(%3V<FYG<F5N"DQA<W-E($AI;&QE<OAE(%!E=&5R<V5N
636 M("!<(")-:6X@:V%E<&AE<W0@:&%R(&9A865T(&5T(&9O96PA(@I!87)H=7,@
637 M56YI=F5R<VET>2P@1$5.34%22R`@7"`B36EN(&OF<&AE<W0@:&%R(&;E970@
638 )970@9OAL(2(*
639 eofeof
640
641 # Without -l, ISO-8859-1 was handled as X0201.
642
643 printf "%-40s", "MIME ISO-8859-1 (Q)";
644     &test("$nkf -jml",$example{'mime.is8859'},$example{'mime.is8859.ans'});
645
646 # test for -f is not so simple.
647
648 print "\nBug Fixes\n\n";
649
650 # test_data/cr
651
652 $example{'test_data/cr'} = unpack('u',<<'eofeof');
653 1I,:DN:3(#71E<W0-=&5S=`T`
654 eofeof
655
656 $example{'test_data/cr.ans'} = unpack('u',<<'eofeof');
657 7&R1")$8D.21(&RA""G1E<W0*=&5S=`H`
658 eofeof
659
660 printf "%-40s", "test_data/cr";
661     &test("$nkf -jd",$example{'test_data/cr'},$example{'test_data/cr.ans'});
662 # test_data/fixed-qencode
663
664 $example{'test_data/fixed-qencode'} = unpack('u',<<'eofeof');
665 M("`@("`@("`],4(D0CYE/STS1#TQ0BA""B`@("`@("`@/3%")$(^93TS1CTS
666 '1#TQ0BA""@``
667 eofeof
668
669 $example{'test_data/fixed-qencode.ans'} = unpack('u',<<'eofeof');
670 F("`@("`@("`;)$(^93\]&RA""B`@("`@("`@&R1"/F4_/1LH0@H`
671 eofeof
672
673 printf "%-40s", "test_data/fixed-qencode";
674     &test("$nkf -jmQ",$example{'test_data/fixed-qencode'},$example{'test_data/fixed-qencode.ans'});
675 # test_data/long-fold-1
676
677 $example{'test_data/long-fold-1'} = unpack('u',<<'eofeof');
678 MI,JDK*2DI,JDK*2DI,JDK*'!I*2DKJ3GI*:DK*2BI.JDWJ2WI,:AHJ2SI.RD
679 M\J2]I,ZDWJ3>I**DQ*2KI*:DR*&BI,FDIJ3BI-^DT*2HI*RD[Z3KI*2DMZ&B
680 MI,BDP:3EI*:DQZ3!I.>D\Z2NI.RDZZ2KI.*DMZ3SI,JDI*&C"J2SI+.DSR!#
681 M4B],1B"DSKG4H:,-"J2SI+.DSR!#4B"DSKG4H:,-I+.DLZ3/($Q&+T-2(*3.
682 9N=2AHPH-"J2SI+.DSR!,1B"DSKG4H:,*"@``
683 eofeof
684
685 $example{'test_data/long-fold-1.ans'} = unpack('u',<<'eofeof');
686 M&R1")$HD+"0D)$HD+"0D)$HD+"%!)"0D+B1G)"8D+"0B)&HD7B0W)$8A(B0S
687 M)&PD<B0])$XD7B1>)"(D1"0K&RA""ALD0B0F)$@A(B1))"8D8B1?)%`D*"0L
688 M)&\D:R0D)#<A(B1()$$D920F)$<D021G)',D+B1L)&LD*R1B)#<D<QLH0@H;
689 M)$(D2B0D(2,;*$(*&R1")#,D,R1/&RA"($-2+TQ&(!LD0B1..50A(QLH0@H;
690 M)$(D,R0S)$\;*$(@0U(@&R1")$XY5"$C&RA""ALD0B0S)#,D3QLH0B!,1B]#
691 M4B`;)$(D3CE4(2,;*$(*"ALD0B0S)#,D3QLH0B!,1B`;)$(D3CE4(2,;*$(*
692 !"@``
693 eofeof
694
695 printf "%-40s", "test_data/long-fold-1";
696     &test("$nkf -jF60",$example{'test_data/long-fold-1'},$example{'test_data/long-fold-1.ans'});
697 # test_data/long-fold
698
699 $example{'test_data/long-fold'} = unpack('u',<<'eofeof');
700 MI,JDK*2DI,JDK*2DI,JDK*'!I*2DKJ3GI*:DK*2BI.JDWJ2WI,:AHJ2SI.RD
701 M\J2]I,ZDWJ3>I**DQ*2KI*:DR*&BI,FDIJ3BI-^DT*2HI*RD[Z3KI*2DMZ&B
702 MI,BDP:3EI*:DQZ3!I.>D\Z2NI.RDZZ2KI.*DMZ3SI,JDI*&C"J2SI+.DS\.[
703 'I*2YU*&C"@``
704 eofeof
705
706 $example{'test_data/long-fold.ans'} = unpack('u',<<'eofeof');
707 M&R1")$HD+"0D)$HD+"0D)$HD+"%!)"0D+B1G)"8D+"0B)&HD7B0W)$8A(B0S
708 M)&PD<B0])$XD7B1>)"(D1"0K&RA""ALD0B0F)$@A(B1))"8D8B1?)%`D*"0L
709 M)&\D:R0D)#<A(B1()$$D920F)$<D021G)',D+B1L)&LD*R1B)#<D<QLH0@H;
710 :)$(D2B0D(2,D,R0S)$]#.R0D.50A(QLH0@H`
711 eofeof
712
713 printf "%-40s", "test_data/long-fold";
714     &test("$nkf -jf60",$example{'test_data/long-fold'},$example{'test_data/long-fold.ans'});
715 # test_data/mime_out
716
717 $example{'test_data/mime_out'} = unpack('u',<<'eofeof');
718 M"BTM+2T*4W5B:F5C=#H@86%A82!A86%A(&%A86$@86%A82!A86%A(&%A86$@
719 M86%A82!A86%A(&%A86$@86%A82!A86%A(&%A86$@86%A82!A86%A"BTM+2T*
720 M4W5B:F5C=#H@I**DI*2FI*BDJJ2KI*VDKZ2QI+.DM:2WI+FDNZ2]I+^DP:3$
721 MI,:DR*3*I,NDS*3-I,ZDSZ32I-6DV*3;I-ZDWZ3@I.&DXJ3DI*2DYJ2HI.@*
722 M+2TM+0I3=6)J96-T.B!A86%A(&%A86$@86%A82!A86%A(&%A86$@86%A82!A
723 I86%A(*2BI*2DIJ2HI*H@86%A82!A86%A(&%A86$@86%A80HM+2TM"@H`
724 eofeof
725
726 $example{'test_data/mime_out.ans'} = unpack('u',<<'eofeof');
727 M"BTM+2T*4W5B:F5C=#H@86%A82!A86%A(&%A86$@86%A82!A86%A(&%A86$@
728 M86%A82!A86%A(&%A86$@86%A82!A86%A(&%A86$@86%A80H@86%A80HM+2TM
729 M"E-U8FIE8W0Z(#T_25-/+3(P,C(M2E`_0C]'>5)#2D-):TI#46U*0V=K2VE1
730 M<DI#,&M,>5%X2D1-:TY343-*1&MB2T5)/3\]"B`]/TE33RTR,#(R+4I0/T(_
731 M1WE20TI$<VM04U$O2D5%:U)#4D=*16=K4VE23$I%=VM44U)/2D4X:U5I4E9*
732 M1F=B2T5)/3\]"B`]/TE33RTR,#(R+4I0/T(_1WE20TI&<VM8:5)F2D=!:UE3
733 M4FE*1U%K2D-2;4I#9VMA0G-O46<]/3\]"BTM+2T*4W5B:F5C=#H@86%A82!A
734 M86%A(&%A86$@86%A82!A86%A(&%A86$@86%A80H@/3])4T\M,C`R,BU*4#]"
735 M/T=Y4D-*0TEK2D-1;4I#9VM+:'-O46<]/3\](&%A86$@86%A82!A86%A(&%A
736 )86$*+2TM+0H*
737 eofeof
738
739 $example{'test_data/mime_out.ans.alt'} = unpack('u',<<'eofeof');
740 M"BTM+2T*4W5B:F5C=#H@86%A82!A86%A(&%A86$@86%A82!A86%A(&%A86$@
741 M86%A82!A86%A(&%A86$*(&%A86$@86%A82!A86%A(&%A86$@86%A80HM+2TM
742 M"E-U8FIE8W0Z(#T_25-/+3(P,C(M2E`_0C]'>5)#2D-):TI#46U*0V=K2VE1
743 M<DI#,&M,>5%X2D1-:TY343-'>6A#/ST*(#T_25-/+3(P,C(M2E`_0C]'>5)#
744 M2D1K:T]Y43E*1#AK45-214I%66M30U)+2D5S:U1#4DY*131K5'E24TI&56M7
745 M0U)B1WEH0S\]"B`]/TE33RTR,#(R+4I0/T(_1WE20TI&-&M8>5)G2D=%:UEI
746 M4FM*0U%K6FE1;TI'9V)+14D]/ST*+2TM+0I3=6)J96-T.B!A86%A(&%A86$@
747 M86%A82!A86%A(&%A86$@86%A82!A86%A"B`]/TE33RTR,#(R+4I0/T(_1WE2
748 M0TI#26M*0U%M2D-G:TMH<V]19ST]/ST@86%A82!A86%A(&%A86$*(&%A86$*
749 &+2TM+0H*
750 eofeof
751
752 $example{'test_data/mime_out.ans.alt2'} = unpack('u',<<'eofeof');
753 M"BTM+2T*4W5B:F5C=#H@86%A82!A86%A(&%A86$@86%A82!A86%A(&%A86$@
754 M86%A82!A86%A(&%A86$@86%A82!A86%A(&%A86$@86%A80H@86%A80HM+2TM
755 M"E-U8FIE8W0Z(#T_25-/+3(P,C(M2E`_0C]'>5)#2D-):TI#46U*0V=K2VE1
756 M<DI#,&M,>5%X2D1-:TY343-*1&MK3WE1.4=Y:$,_/0H@/3])4T\M,C`R,BU*
757 M4#]"/T=Y4D-*1#AK45-214I%66M30U)+2D5S:U1#4DY*131K5'E24TI&56M7
758 M0U)B2D8T:UAY4F='>6A#/ST*(#T_25-/+3(P,C(M2E`_0C]'>5)#2D=%:UEI
759 M4FM*0U%K6FE1;TI'9V)+14D]/ST*+2TM+0I3=6)J96-T.B!A86%A(&%A86$@
760 M86%A82!A86%A(&%A86$@86%A82!A86%A(#T_25-/+3(P,C(M2E`_0C]'>5)#
761 M2D-):TI"<V]19ST]/ST*(#T_25-/+3(P,C(M2E`_0C]'>5)#2D-9:TM#47%'
762 @>6A#/ST@86%A82!A86%A(&%A86$@86%A80HM+2TM"@H`
763 eofeof
764
765 $example{'test_data/mime_out.ans.alt3'} = unpack('u',<<'eofeof');
766 M"BTM+2T*4W5B:F5C=#H@86%A82!A86%A(&%A86$@86%A82!A86%A(&%A86$@
767 M86%A82!A86%A(&%A86$@86%A82!A86%A(&%A86$@86%A80H@86%A80HM+2TM
768 M"E-U8FIE8W0Z(#T_25-/+3(P,C(M2E`_0C]'>5)#2D-):TI#46U*0V=K2VE1
769 M<DI#,&M,>5%X2D1-:TY343-*1&MK3WE1.4=Y:$,_/0H@/3])4T\M,C`R,BU*
770 M4#]"/T=Y4D-*1#AK45-214I%66M30U)+2D5S:U1#4DY*131K5'E24TI&56M7
771 M0U)B2D8T:UAX<V]19ST]/ST*(#T_25-/+3(P,C(M2E`_0C]'>5)#2D=!:UE3
772 M4FE*1U%K2D-2;4I#9VMA0G-O46<]/3\]"BTM+2T*4W5B:F5C=#H@86%A82!A
773 M86%A(&%A86$@86%A82!A86%A(&%A86$@86%A82`]/TE33RTR,#(R+4I0/T(_
774 M1WE20TI#26M*0G-O46<]/3\]"B`]/TE33RTR,#(R+4I0/T(_1WE20TI#66M+
775 D0U%Q1WEH0S\](&%A86$@86%A82!A86%A(&%A86$*+2TM+0H*1
776 eofeof
777
778 printf "%-40s", "test_data/mime_out";
779     &test("$nkf -jM",$example{'test_data/mime_out'},$example{'test_data/mime_out.ans'},$example{'test_data/mime_out.ans.alt'},$example{'test_data/mime_out.ans.alt2'},$example{'test_data/mime_out.ans.alt3'});
780 # test_data/mime_out3
781
782 $example{'test_data/mime_out3'} = "\x82\xD9\x82\xB0 A";
783
784 $example{'test_data/mime_out3.ans'} = "=?ISO-2022-JP?B?GyRCJFskMhsoQg==?= A";
785
786 printf "%-40s", "test_data/mime_out3";
787     &test("$nkf -jSM",$example{'test_data/mime_out3'},$example{'test_data/mime_out3.ans'});
788 # test_data/multi-line
789
790 $example{'test_data/multi-line'} = unpack('u',<<'eofeof');
791 MI,JDK*2DI,JDK*2DI,JDK*'!I*2DKJ3GI*:DK*2BI.JDWJ2WI,:AH@"DLZ3L
792 MI/*DO:3.I-ZDWJ2BI,2DJZ2FI,BAHJ3)I*:DXJ3?I-"DJ*2LI.^DZZ2DI+>A
793 MHJ3(I,&DY:2FI,>DP:3GI/.DKJ3LI.NDJZ3BI+>D\Z3*I*2AHPJDLZ2SI,_#
794 8NZ2DN=2AHP`*I+.DLZ3/P[NDI+G4H:,*
795 eofeof
796
797 $example{'test_data/multi-line.ans'} = unpack('u',<<'eofeof');
798 MI,JDK*2DI,JDK*2DI,JDK*'!I*2DKJ3GI*:DK*2BI.JDWJ2WI,:AH@"DLZ3L
799 MI/*DO:3.I-ZDWJ2BI,2DJZ2FI,BAHJ3)I*:DXJ3?I-"DJ*2LI.^DZZ2DI+>A
800 MHJ3(I,&DY:2FI,>DP:3GI/.DKJ3LI.NDJZ3BI+>D\Z3*I*2AHPJDLZ2SI,_#
801 8NZ2DN=2AHP`*I+.DLZ3/P[NDI+G4H:,*
802 eofeof
803
804 printf "%-40s", "test_data/multi-line";
805     &test("$nkf -e",$example{'test_data/multi-line'},$example{'test_data/multi-line.ans'});
806 # test_data/-Z4
807
808 $example{'test_data/-Z4'} = unpack('u',<<'eofeof');
809 MH:.AUJ'7H:*AIJ&\H:NAK*6AI:*EHZ6DI:6EIJ6GI:BEJ:6JI:NEK*6MI:ZE
810 MKZ6PI;&ELJ6SI;2EM:6VI;>EN*6YI;JENZ6\I;VEOJ6_I<"EP:7"I<.EQ*7%
811 MI<:EQZ7(I<FERJ7+I<RES:7.I<^ET*71I=*ETZ74I=6EUJ77I=BEV:7:I=NE
812 KW*7=I=ZEWZ7@I>&EXJ7CI>2EY:7FI>>EZ*7II>JEZZ7LI>VE[Z7RI?.E]```
813 eofeof
814
815 $example{'test_data/-Z4.ans'} = unpack('u',<<'eofeof');
816 MCJ&.HHZCCJ2.I8ZPCMZ.WXZGCK&.J(ZRCJF.LXZJCK2.JXZUCK:.MH[>CK>.
817 MMX[>CKB.N([>CKF.N8[>CKJ.NH[>CKN.NX[>CKR.O([>CKV.O8[>CKZ.OH[>
818 MCK^.OX[>CL".P([>CL&.P8[>CJ^.PH["CMZ.PX[#CMZ.Q([$CMZ.Q8[&CL>.
819 MR([)CLJ.RH[>CLJ.WX[+CLN.WH[+CM^.S([,CMZ.S([?CLV.S8[>CLV.WX[.
820 MCLZ.WH[.CM^.SX[0CM&.TH[3CJR.U(ZMCM6.KH[6CM>.V([9CMJ.VX[<CJ:.
821 %W8ZSCMX`
822 eofeof
823
824 printf "%-40s", "test_data/-Z4    ";
825     &test("$nkf -eEZ4",$example{'test_data/-Z4'},$example{'test_data/-Z4.ans'});
826 # test_data/nkf-19-bug-1
827
828 $example{'test_data/nkf-19-bug-1'} = unpack('u',<<'eofeof');
829 ,I*:DJZ2D"KK8QJ,*
830 eofeof
831
832 $example{'test_data/nkf-19-bug-1.ans'} = unpack('u',<<'eofeof');
833 8&R1")"8D*R0D&RA""ALD0CI81B,;*$(*
834 eofeof
835
836 printf "%-40s", "test_data/nkf-19-bug-1";
837     &test("$nkf -Ej",$example{'test_data/nkf-19-bug-1'},$example{'test_data/nkf-19-bug-1.ans'});
838 # test_data/nkf-19-bug-2
839
840 $example{'test_data/nkf-19-bug-2'} = unpack('u',<<'eofeof');
841 %I-NDL@H`
842 eofeof
843
844 $example{'test_data/nkf-19-bug-2.ans'} = unpack('u',<<'eofeof');
845 %I-NDL@H`
846 eofeof
847
848 printf "%-40s", "test_data/nkf-19-bug-2";
849     &test("$nkf -Ee",$example{'test_data/nkf-19-bug-2'},$example{'test_data/nkf-19-bug-2.ans'});
850 # test_data/nkf-19-bug-3
851
852 $example{'test_data/nkf-19-bug-3'} = unpack('u',<<'eofeof');
853 8[;'Q\,&L"N6ZSN\*\NT)ON7.SL_+"0D*
854 eofeof
855
856 $example{'test_data/nkf-19-bug-3.ans'} = unpack('u',<<'eofeof');
857 8[;'Q\,&L"N6ZSN\*\NT)ON7.SL_+"0D*
858 eofeof
859
860 printf "%-40s", "test_data/nkf-19-bug-3";
861     &test("$nkf -e",$example{'test_data/nkf-19-bug-3'},$example{'test_data/nkf-19-bug-3.ans'});
862 # test_data/non-strict-mime
863
864 $example{'test_data/non-strict-mime'} = unpack('u',<<'eofeof');
865 M/3])4T\M,C`R,BU*4#]"/PIG<U-#;V]+.6=R-D-O;TQ%9W1Y0W0T1D-$46].
866 M0V\V16=S,D]N;T999S1Y1%=)3$IG=4-0:UD*2W!G<FU#>$E+:6=R,D-V;TMI
867 ,9W-30V]O3&,*/ST*
868 eofeof
869
870 $example{'test_data/non-strict-mime.ans'} = unpack('u',<<'eofeof');
871 M&R1")$8D)"0_)$`D)"1&)%XD.2$C&RA"#0H-"ALD0CMD)$\[?B$Y)6PE.21+
872 <)&(]<20K)#LD1B0D)#\D0"0D)$8D)"1>&RA""@``
873 eofeof
874
875 printf "%-40s", "test_data/non-strict-mime";
876     &test("$nkf -jmN",$example{'test_data/non-strict-mime'},$example{'test_data/non-strict-mime.ans'});
877 # test_data/q-encode-softrap
878
879 $example{'test_data/q-encode-softrap'} = unpack('u',<<'eofeof');
880 H/3%")$(T03MZ)3T*,R$\)4DD3CTQ0BA""CTQ0B1"2E$T.3TQ0BA""@``
881 eofeof
882
883 $example{'test_data/q-encode-softrap.ans'} = unpack('u',<<'eofeof');
884 >&R1"-$$[>B4S(3PE221.&RA""ALD0DI1-#D;*$(*
885 eofeof
886
887 printf "%-40s", "test_data/q-encode-softrap";
888     &test("$nkf -jmQ",$example{'test_data/q-encode-softrap'},$example{'test_data/q-encode-softrap.ans'});
889 # test_data/rot13
890
891 $example{'test_data/rot13'} = unpack('u',<<'eofeof');
892 MI+.D\Z3+I,&DSZ&BS:W"]*3(I*2DI*3>I+FAHPH*;FMF('9E<BXQ+CDR(*3R
893 MS?C-T:2UI+NDQJ2DI+^DP*2DI,:DI*3>I+FDK*&B05-#24D@I,O"T*2WI,8@
894 M4D]4,3,@I*P*P+6DMZ2OQK"DI*3&I*2DRJ2DI.BDIJ3'H:*PRK*\I,ZDZ*2F
895 MI,O*T;2YI+6D[*3>I+ND\Z&C"@HE(&5C:&\@)VAO9V4G('P@;FMF("UR"FAO
896 #9V4*
897 eofeof
898
899 $example{'test_data/rot13.ans'} = unpack('u',<<'eofeof');
900 M&R1"4V)31%-Z4W!3?E!1?%QQ15-W4U-34U,O4VA04ALH0@H*87AS(&ER92XQ
901 M+CDR(!LD0E-#?$E\(E-D4VI3=5-34VY3;U-34W534U,O4VA36U!1&RA"3D90
902 M5E8@&R1"4WIQ(5-F4W4;*$(@14)',3,@&R1"4UL;*$(*&R1";V139E->=5]3
903 M4U-U4U-3>5-34SE355-V4%%?>6%K4WU3.5-54WIY(F-H4V13/5,O4VI31%!2
904 A&RA""@HE(')P=6(@)W5B='(G('P@87AS("UE"G5B='(*
905 eofeof
906
907 printf "%-40s", "test_data/rot13";
908     &test("$nkf -jr",$example{'test_data/rot13'},$example{'test_data/rot13.ans'});
909 # test_data/slash
910
911 $example{'test_data/slash'} = unpack('u',<<'eofeof');
912 7("`]/U8\5"U5.5=%2RTK.U<U32LE+PH`
913 eofeof
914
915 $example{'test_data/slash.ans'} = unpack('u',<<'eofeof');
916 7("`]/U8\5"U5.5=%2RTK.U<U32LE+PH`
917 eofeof
918
919 printf "%-40s", "test_data/slash";
920     &test("$nkf -j",$example{'test_data/slash'},$example{'test_data/slash.ans'});
921 # test_data/z1space-0
922
923 $example{'test_data/z1space-0'} = unpack('u',<<'eofeof');
924 "H:$`
925 eofeof
926
927 $example{'test_data/z1space-0.ans'} = unpack('u',<<'eofeof');
928 "H:$`
929 eofeof
930
931 printf "%-40s", "test_data/z1space-0";
932     &test("$nkf -e -Z",$example{'test_data/z1space-0'},$example{'test_data/z1space-0.ans'});
933 # test_data/z1space-1
934
935 $example{'test_data/z1space-1'} = unpack('u',<<'eofeof');
936 "H:$`
937 eofeof
938
939 $example{'test_data/z1space-1.ans'} = unpack('u',<<'eofeof');
940 !(```
941 eofeof
942
943 printf "%-40s", "test_data/z1space-1";
944     &test("$nkf -e -Z1",$example{'test_data/z1space-1'},$example{'test_data/z1space-1.ans'});
945 # test_data/z1space-2
946
947 $example{'test_data/z1space-2'} = unpack('u',<<'eofeof');
948 "H:$`
949 eofeof
950
951 $example{'test_data/z1space-2.ans'} = unpack('u',<<'eofeof');
952 "("``
953 eofeof
954
955 printf "%-40s", "test_data/z1space-2";
956     &test("$nkf -e -Z2",$example{'test_data/z1space-2'},$example{'test_data/z1space-2.ans'});
957 # test_data/bug2273
958
959 $example{'test_data/bug2273'} = unpack('u',<<'eofeof');
960 M/3]I<V\M,C`R,BUJ<#]Q/STY-CU!,CTX1CU",STY,3U&.#TX1$P].$0].3`]
961 M.#$]038*:'1T<#HO+V5X86UP;&4N8V]M+S]O<&4]<V5L"FAT='`Z+R]E>&UA
962 ,<&QE+FIP+PHN+BX*
963 eofeof
964
965 $example{'test_data/bug2273.ans'} = unpack('u',<<'eofeof');
966 MS*2^M<+ZN:VY\**H"FAT='`Z+R]E>&%M<&QE+F-O;2\_;W!E/7-E;`IH='1P
967 3.B\O97AM87!L92YJ<"\*+BXN"@``
968 eofeof
969
970 printf "%-40s", "test_data/bug2273";
971     &test("$nkf -e",$example{'test_data/bug2273'},$example{'test_data/bug2273.ans'});
972 # test_data/forum15899
973
974 $example{'test_data/forum15899'} = unpack('u',<<'eofeof');
975 I6#H@XX&"XX&$XX&&XX&(XX&*XX&+XX&-XX&/XX&1XX&3XX&5(..!EPH`
976 eofeof
977
978 $example{'test_data/forum15899.ans'} = unpack('u',<<'eofeof');
979 M6#H@/3])4T\M,C`R,BU*4#]"/T=Y4D-*0TEK2D-1;4I#9VM+:5%R2D,P:TQY
980 =47A*1$UK3E)S;U%I06)*14EK3GAS;U%G/3T_/0H`
981 eofeof
982
983 printf "%-40s", "test_data/forum15899";
984     &test("$nkf -Mj",$example{'test_data/forum15899'},$example{'test_data/forum15899.ans'});
985 # test_data/bugs10904
986
987 $example{'test_data/bugs10904'} = unpack('u',<<'eofeof');
988 M4W5B:F5C=#H@Z*FFZ:B3YY2HXX.AXX.\XX.KZ*&HZ:&,(.BIINFHD^>4J..#
989 MH>.#O..#J^BAJ.FAC"#HJ:;IJ)/GE*CC@Z'C@[SC@ZOHH:CIH8P@Z*FFZ:B3
990 3YY2HXX.AXX.\XX.KZ*&HZ:&,"@``
991 eofeof
992
993 $example{'test_data/bugs10904.ans'} = unpack('u',<<'eofeof');
994 M4W5B:F5C=#H@/3])4T\M,C`R,BU*4#]"/T=Y4D-/,C0T33`Q4DI716A00U9R
995 ?4U0Q0V%H<V]1:4%B2D5)-V)J9WI45D5B2T5)/3\]"@``
996 M(#T_25-/+3(P,C(M2E`_0C]'>5)#2E=%:%!#5G)35#%#86AS;U%I06)*14DW
997 ?8FIG>E1616Q94T4X2E=T2E!52G%'>6A#24$]/3\]"@``
998 M(#T_25-/+3(P,C(M2E`_0C]'>5)#3S(T-$TP,5)*5T5H4$-6<E-4,4-A:'-O
999 '46<]/3\]"@``
1000 eofeof
1001
1002 printf "%-40s", "test_data/bugs10904";
1003     &test("$nkf -Mj",$example{'test_data/bugs10904'},$example{'test_data/bugs10904.ans'});
1004
1005 printf "%-40s", "test_data/ruby-dev:39722";
1006     &test("$nkf -Mj",<<eom,<<eom);
1007 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaあ
1008 eom
1009 =?US-ASCII?Q?aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa?=
1010  =?US-ASCII?Q?aaaaaaaaaaaaaaaaa?= =?ISO-2022-JP?B?GyRCJCIbKEI=?=
1011 eom
1012 # test_data/bug19779
1013
1014 $example{'test_data/bug19779'} = unpack('u',<<'eofeof');
1015 2&R1","$;*$(*&R1"7V8;*$(*
1016 eofeof
1017
1018 $example{'test_data/bug19779.ans'} = unpack('u',<<'eofeof');
1019 M/3])4T\M,C`R,BU*4#]"/T=Y4D--0T5B2T5)/3\]"CT_25-/+3(P,C(M2E`_
1020 10C]'>5)#6#)98DM%23T_/0H`
1021 eofeof
1022
1023 printf "%-40s",  "test_data/bug19779    ";
1024     &test("$nkf -jM",$example{'test_data/bug19779'},$example{'test_data/bug19779.ans'});
1025
1026 printf "%-40s",  "[nkf-forum:47327]    ";
1027     &test("$nkf -wM",pack('H*','feffd852de76d814dc45000a'),"=?UTF-8?B?8KSptvCVgYU=?=\n");
1028
1029 printf "%-40s",  "[nkf-forum:47334]    ";
1030     &test("$nkf -w",pack('H*','feff006100620063000a'),"abc\n");
1031
1032 printf "%-40s",  "[nkf-bug:20079]    ";
1033     &test("$nkf -jSxM","\xBB \xBB","=?ISO-2022-JP?B?GyhJOxsoQiAbKEk7GyhC?=");
1034
1035 printf "%-40s",  "[nkf-forum:48850]    ";
1036     &test("$nkf -jSM",
1037         "From: \x82\xA0\x82\xA0\x82\xA0\x82\xA0\x82\xA0\x82\xA0\x82\xA0\x82\xA0\x82\xA0" .
1038         " <x-xxxx@xxxxxxxxxxxx.co.jp>\n",
1039         "From: =?ISO-2022-JP?B?GyRCJCIkIiQiJCIkIiQiJCIkIiQiGyhC?=" .
1040         " <x-xxxx@xxxxxxxxxxxx.co.jp>\n");
1041
1042 printf "%-40s",  "[nkf-bug:21393]-x  ";
1043     &test("$nkf --ic=UTF-8 --oc=CP932",
1044     "\xEF\xBD\xBC\xEF\xBE\x9E\xEF\xBD\xAC\xEF\xBD\xB0\xEF\xBE\x8F\xEF\xBE\x9D\xEF\xBD\xA5\xEF\xBE\x8E\xEF\xBE\x9F\xEF\xBE\x83\xEF\xBE\x84\xEF\xBD\xA1",
1045     "\xBC\xDE\xAC\xB0\xCF\xDD\xA5\xCE\xDF\xC3\xC4\xA1");
1046
1047 printf "%-40s",  "[nkf-bug:21393]-X  ";
1048     &test("$nkf --ic=UTF-8 --oc=CP932 -X",
1049     "\xEF\xBD\xBC\xEF\xBE\x9E\xEF\xBD\xAC\xEF\xBD\xB0\xEF\xBE\x8F\xEF\xBE\x9D\xEF\xBD\xA5\xEF\xBE\x8E\xEF\xBE\x9F\xEF\xBE\x83\xEF\xBE\x84\xEF\xBD\xA1",
1050     "\x83W\x83\x83\x81[\x83}\x83\x93\x81E\x83|\x83e\x83g\x81B");
1051
1052     if (!NKF) {
1053 printf "%-40s", "Guess NL";
1054 &command_tests(
1055         "$nkf --guess","none",      "ASCII\n",
1056         "$nkf --guess","\n",        "ASCII (LF)\n",
1057         "$nkf --guess","\n\n",      "ASCII (LF)\n",
1058         "$nkf --guess","\n\r",      "ASCII (MIXED NL)\n",
1059         "$nkf --guess","\n\r\n",    "ASCII (MIXED NL)\n",
1060         "$nkf --guess","\n.\n",     "ASCII (LF)\n",
1061         "$nkf --guess","\n.\r",     "ASCII (MIXED NL)\n",
1062         "$nkf --guess","\n.\r\n",   "ASCII (MIXED NL)\n",
1063         "$nkf --guess","\r",        "ASCII (CR)\n",
1064         "$nkf --guess","\r\r",      "ASCII (CR)\n",
1065         "$nkf --guess","\r\r\n",    "ASCII (MIXED NL)\n",
1066         "$nkf --guess","\r.\n",     "ASCII (MIXED NL)\n",
1067         "$nkf --guess","\r.\r",     "ASCII (CR)\n",
1068         "$nkf --guess","\r.\r\n",   "ASCII (MIXED NL)\n",
1069         "$nkf --guess","\r\n",      "ASCII (CRLF)\n",
1070         "$nkf --guess","\r\n\n",    "ASCII (MIXED NL)\n",
1071         "$nkf --guess","\r\n\r",    "ASCII (MIXED NL)\n",
1072         "$nkf --guess","\r\n\r\n",  "ASCII (CRLF)\n",
1073         "$nkf --guess","\r\n.\n",   "ASCII (MIXED NL)\n",
1074         "$nkf --guess","\r\n.\r",   "ASCII (MIXED NL)\n",
1075         "$nkf --guess","\r\n.\r\n", "ASCII (CRLF)\n");
1076     }
1077
1078 printf "%-40s", "Convert NL to LF";
1079 &command_tests(
1080         "$nkf -jLu","none",      "none",
1081         "$nkf -jLu","\n",        "\n",
1082         "$nkf -jLu","\n\n",      "\n\n",
1083         "$nkf -jLu","\n\r",      "\n\n",
1084         "$nkf -jLu","\n\r\n",    "\n\n",
1085         "$nkf -jLu","\n.\n",     "\n.\n",
1086         "$nkf -jLu","\n.\r",     "\n.\n",
1087         "$nkf -jLu","\n.\r\n",   "\n.\n",
1088         "$nkf -jLu","\r",        "\n",
1089         "$nkf -jLu","\r\r",      "\n\n",
1090         "$nkf -jLu","\r\r\n",    "\n\n",
1091         "$nkf -jLu","\r.\n",     "\n.\n",
1092         "$nkf -jLu","\r.\r",     "\n.\n",
1093         "$nkf -jLu","\r.\r\n",   "\n.\n",
1094         "$nkf -jLu","\r\n",      "\n",
1095         "$nkf -jLu","\r\n\n",    "\n\n",
1096         "$nkf -jLu","\r\n\r",    "\n\n",
1097         "$nkf -jLu","\r\n\r\n",  "\n\n",
1098         "$nkf -jLu","\r\n.\n",   "\n.\n",
1099         "$nkf -jLu","\r\n.\r",   "\n.\n",
1100         "$nkf -jLu","\r\n.\r\n", "\n.\n");
1101
1102 printf "%-40s", "Convert NL to LF";
1103 &command_tests(
1104         "$nkf -jLm","none",      "none",
1105         "$nkf -jLm","\n",        "\r",
1106         "$nkf -jLm","\n\n",      "\r\r",
1107         "$nkf -jLm","\n\r",      "\r\r",
1108         "$nkf -jLm","\n\r\n",    "\r\r",
1109         "$nkf -jLm","\n.\n",     "\r.\r",
1110         "$nkf -jLm","\n.\r",     "\r.\r",
1111         "$nkf -jLm","\n.\r\n",   "\r.\r",
1112         "$nkf -jLm","\r",        "\r",
1113         "$nkf -jLm","\r\r",      "\r\r",
1114         "$nkf -jLm","\r\r\n",    "\r\r",
1115         "$nkf -jLm","\r.\n",     "\r.\r",
1116         "$nkf -jLm","\r.\r",     "\r.\r",
1117         "$nkf -jLm","\r.\r\n",   "\r.\r",
1118         "$nkf -jLm","\r\n",      "\r",
1119         "$nkf -jLm","\r\n\n",    "\r\r",
1120         "$nkf -jLm","\r\n\r",    "\r\r",
1121         "$nkf -jLm","\r\n\r\n",  "\r\r",
1122         "$nkf -jLm","\r\n.\n",   "\r.\r",
1123         "$nkf -jLm","\r\n.\r",   "\r.\r",
1124         "$nkf -jLm","\r\n.\r\n", "\r.\r");
1125
1126 printf "%-40s", "Convert NL to CRLF";
1127 &command_tests(
1128         "$nkf -jLw","none",      "none",
1129         "$nkf -jLw","\n",        "\r\n",
1130         "$nkf -jLw","\n\n",      "\r\n\r\n",
1131         "$nkf -jLw","\n\r",      "\r\n\r\n",
1132         "$nkf -jLw","\n\r\n",    "\r\n\r\n",
1133         "$nkf -jLw","\n.\n",     "\r\n.\r\n",
1134         "$nkf -jLw","\n.\r",     "\r\n.\r\n",
1135         "$nkf -jLw","\n.\r\n",   "\r\n.\r\n",
1136         "$nkf -jLw","\r",        "\r\n",
1137         "$nkf -jLw","\r\r",      "\r\n\r\n",
1138         "$nkf -jLw","\r\r\n",    "\r\n\r\n",
1139         "$nkf -jLw","\r.\n",     "\r\n.\r\n",
1140         "$nkf -jLw","\r.\r",     "\r\n.\r\n",
1141         "$nkf -jLw","\r.\r\n",   "\r\n.\r\n",
1142         "$nkf -jLw","\r\n",      "\r\n",
1143         "$nkf -jLw","\r\n\n",    "\r\n\r\n",
1144         "$nkf -jLw","\r\n\r",    "\r\n\r\n",
1145         "$nkf -jLw","\r\n\r\r\n",  "\r\n\r\n\r\n",
1146         "$nkf -jLw","\r\n.\n",   "\r\n.\r\n",
1147         "$nkf -jLw","\r\n.\r",   "\r\n.\r\n",
1148         "$nkf -jLw","\r\n.\r\n", "\r\n.\r\n");
1149 # end