OSDN Git Service

Revert c7f07b3aaf5921647bd66a6ceb8f9741900bf4b2
[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 $example{'jisx0213_utf8'} = unpack('u',<<'eofeof');
361 :[[R'Y:REY:V!Y;>+Y;>BZ;ZB\*""B?"JFK(`
362 eofeof
363
364 printf "%-40s", "Shift_JISX0213 to EUC-JISX0213";
365     &test("$nkf --ic=Shift_JISX0213 --oc=EUC-JISX0213",$example{'jisx0213_sjis'},$example{'jisx0213_euc'});
366
367 printf "%-40s", "EUC-JISX0213 to Shift_JISX0213";
368     &test("$nkf --ic=EUC-JISX0213 --oc=Shift_JISX0213",$example{'jisx0213_euc'},$example{'jisx0213_sjis'});
369
370 printf "%-40s", "ISO-2022-JP-3 to EUC-JISX0213";
371     &test("$nkf --ic=ISO-2022-JP-3 --oc=EUC-JISX0213",$example{'jisx0213_jis2000'},$example{'jisx0213_euc'});
372
373 printf "%-40s", "ISO-2022-JP-2004 to EUC-JISX0213";
374     &test("$nkf --ic=ISO-2022-JP-2004 --oc=EUC-JISX0213",$example{'jisx0213_jis2004'},$example{'jisx0213_euc'});
375
376 printf "%-40s", "EUC-JISX0213 to ISO-2022-JP-2004";
377     &test("$nkf --ic=EUC-JISX0213 --oc=ISO-2022-JP-2004",$example{'jisx0213_euc'},$example{'jisx0213_jis2004'});
378
379 printf "%-40s", "EUC-JISX0213 to UTF-8";
380     &test("$nkf --ic=EUC-JISX0213 -w",$example{'jisx0213_euc'},$example{'jisx0213_utf8'});
381
382 printf "%-40s", "UTF-8 to EUC-JISX0213";
383     &test("$nkf -W --oc=EUC-JISX0213",$example{'jisx0213_utf8'},$example{'jisx0213_euc'});
384
385 printf "%-40s",  "ISO-2022-JP-{1,3,2004} to UTF-8";
386     &test("$nkf --ic=iso-2022-jp-2004 -w",
387         "\x1b\$B5Y\x1b\$(O~e\x1b\$(Q.!\x1b\$(P#M\x1b\$(D\\e\x1b(B",
388         "\xe4\xbc\x91\xe9\xb7\x97\xe4\xbf\xb1\xe5\x8c\x8b\xe8\xa4\xb1");
389 printf "%-40s",  "UTF-8 to ISO-2022-JP-2004";
390     &test("$nkf -W --oc=iso-2022-jp-2004",
391         "\xe4\xbc\x91\xe9\xb7\x97\xe4\xbf\xb1\xe5\x8c\x8b\xe8\xa4\xb1",
392         "\x1b\$(Q5Y~e.!\x1b\$(P#M\x1b(B");
393
394 # test_data/jisx0213nonbmp
395
396 $example{'test_data/jisx0213nonbmp'} = unpack('u',<<'eofeof');
397 MKJ*OPJ_,K^"O^\_4S^//[O6Z]?+VJ?:R]N#W[/C^^:GYQ_G4^>[ZW?NS^\G[
398 M[/S)_-'^YH^AH8^AJX^AKH^AMH^AQH^A\(^A]X^A^8^CHH^CI8^CIX^CL8^C
399 MLH^CN(^COX^CP8^CRH^CTH^CTX^CV8^CW(^C]X^DJH^DL8^DLH^DNH^DO8^D
400 MV8^DW(^DWH^DXX^DZH^DZX^D\H^D](^D]8^EI8^ELH^EOH^EQ(^EQX^EU8^E
401 MUH^E_H^HL(^HMX^HN(^HNH^HNX^HOX^HP(^HQ8^HR(^HRH^HRX^HVX^HYH^H
402 M[(^LHH^LJX^LL(^LT(^LY8^L[8^L\H^MI(^MJ8^MJH^MLH^MM(^MM8^MN8^M
403 MUH^M_8^NHX^NI(^NNH^NO(^NO8^NPH^NPX^NQ(^NQX^NR8^NU8^NUH^NUX^N
404 MVX^N]X^N^(^OJH^OOX^OP(^OPH^OPX^OSH^OV8^OX8^OZ8^OZH^O\(^O]8_N
405 MHX_NM(_NR8_NW(_NWH_NWX_NX(_OLH_OQX_OS8_OX8_OY(_PHH_PLX_PN8_P
406 MTX_P^X_QKH_QL(_QM8_QQ(_QW8_QX8_QYH_QZ8_Q]8_Q]X_Q^H_RH8_RHX_R
407 MI(_RJ(_RK(_RO8_RR(_RVX_R]8_R]H_SLH_SO8_SOH_SP(_STH_SW8_SWH_S
408 M\X_S](_S]8_S]X_S^X_S_8_THH_TI(_TIX_TKH_TKX_TM(_TM8_TO8_TPH_T
409 MSX_TZ8_TZX_T\H_T]8_T^8_UM8_UNH_UQH_UUH_UV(_UVH_UW8_UWX_UXX_U
410 MZH_U\(_U\X_VQ(_VSH_VW8_V]8_V_H_WH8_WHH_WLX_WMH_WY(_WY8_WZX_W
411 M[H_W\X_XJ8_XJH_XK(_XM(_XO(_XOH_XPH_XUH_XXX_X]X_X^8_X^H_YI8_Y
412 MKX_YLH_YN8_YPH_YR(_YV8_YWH_YYH_YZX_Y^H_Y_H_ZH8_ZK(_ZKX_ZSX_Z
413 MT(_ZUX_ZY8_ZYH_Z\8_Z\H_Z_H_[H8_[K(_[K8_[MH_[MX_[O8_[OH_[SH_[
414 MSX_[UX_[VH_[W(_[W8_[X8_[Y8_[YX_[Z8_[\8_\HH_\HX_\N(_\PH_\S(_\
415 MUH_\V8_\W8_\]H_]K(_]RX_]S(_]V8_]VX_]W8_]YX_][8_]\(_^I8_^J8_^
416 =JX_^LH_^M8_^TX_^V(_^VH_^[H_^\(_^\H_^]@H`
417 eofeof
418
419 $example{'test_data/jisx0213nonbmp.ans'} = unpack('u',<<'eofeof');
420 M\*"`B_"AB+WPH8R;\*&1KO"AHKWPH*Z?\*&:M/"AN+3PHX>$\*.7A/"CG+_P
421 MHYVC\*.SOO"DG['PI9*.\*64CO"EG;'PI:>$\*6VH?"FJ[_PIKF`\*>#M/"G
422 MFH3PJ(FW\*B/C?"JAI#PH(*)\*""HO"@@J3PH(:B\*"(D_"@C*OPH(Z!\*"-
423 ML?"@C[GPH)&*\*"4B?"@EY;PH)BH\*"=C_"@H(?PH*"Z\*"BN?"@I;SPH*:=
424 M\*"KD_"@K)WPH+6%\*"WH?"@NI7PH+FM\*"YI/"@O9_PH8B!\*&)E?"AB;OP
425 MH8FT\*&+I/"ABY?PH8N]\*&,MO"AC83PH8^$\*&1K?"AEY?PIK"I\*&9A_"A
426 MG(;PH9V"\*&G@_"AL9;PH;2M\*&UA?"AM;CPH;6B\*&VH?"AMISPH;:2\*&V
427 MM_"AMZ#PH;BS\*&\GO"AO;;PH;^Z\**%N_"BC)[PHHZM\**;L_"BH9OPHJ*K
428 M\**FC_"BJKCPHJV/\**MD/"BK8;PHK"=\**NIO"BL*3PHK>A\*.'@_"CA[7P
429 MHX:V\*.-LO"CCY/PHX^2\*./D/"CCZ3PHX^5\*./FO"CCY_PHY&*\*.1D?"C
430 MD8OPHY&E\*.3I/"CE9KPHY:4\*.8N?"CF8?PHYBX\*.8NO"CG)SPHYR,\*.=
431 MI/"CG[_PHY^G\*.@I/"CH+WPHZJ8\*.QO_"CM(#PH[6`\*.WNO"CM[GPH[>3
432 M\*.]OO"D@I;PI(2#\*2'AO"DA[[PI(Z\\*28J?"DFJ7PI**6\*2IC?"DK9;P
433 MI*VO\*2PEO"DM)3PI+B.\*2XM_"DN:KPI+J+\*6!BO"E@97PI82B\*6&J?"E
434 MAZ7PI8>-\*6(GO"EB8SPI9"N\*63F?"EEJ?PI9ZI\*6>M/"EIY3PI:ND\*6K
435 MH_"EJ['PI:ZR\*6QB_"EL:3PI;BN\*6YEO"EN:7PI;FB\*6[F/"ENX+PI;NH
436 M\*6\H_"EO9SPI;^@\*6_E/"F@(SPI;^[\*:`E_"F@:#PIH.M\*:)L/"FBH;P
437 MIHV,\*.TCO"FD(+PIIF^\*::L/"FG)WPIJ.=\*:CJO"FI9'PIJ6O\*:GG?"F
438 MJ)[PIJF8\*:JC/"FJK?PIK&S\*:SG?"FN:7PIKZ4\*:_N/"FO[;PIK^W\*>$
439 MC?"GA+GPIX^;\*>/FO"GC[[PIY"0\*>1B?"GF)7PIYB4\*>8L?"GFI/PIYR.
440 M\*><H_"GG9+PIZ:%\*>JA/"GKK/PIZZ^\*>OA_"GLKCPI[:@\*>XD/"GOK?P
441 MJ(**\*B"N_"HBH+PJ(NS\*B0C/"HD97PJ)6K\*B7B/"HEXGPJ)N7\*B;NO"H
442 MI8GPJ*6&\*BEJ_"HIH?PJ*:(\*BFNO"HIKOPJ*B>\*BHJ?"HJ;'PJ*F#\*BJ
443 MF?"HJXWPJ*ND\*BKG?"HKX'PJ*^O\*BTD/"HM;'PJ+>[\*BXG_"HN+;PJ+J)
444 M\*B[J_"HO++PJ+^X\*F*H/"IBK'PJ9*0\*F7C_"IF;_PJ9NP\*F<F?"IG9#P
445 MJ:.&\*FILO"IMYOPJ;B]\*FXE?"INHKPJ;F)\*F[A/"INZGPJ;N;\*F_CO"J
446 K@*_PJH":\*J#N?"J@H+PHHB8\*J.C/"JD+?PJI>Q\*J8@O"JF)KPJIJR"@``
447 eofeof
448
449 printf "%-40s",  "EUC-JISX0213 to UTF-8 (not in BMP)";
450     &test("$nkf --ic=euc-jisx0213 -w",$example{'test_data/jisx0213nonbmp'},$example{'test_data/jisx0213nonbmp.ans'});
451 printf "%-40s",  "UTF-8 to EUC-JISX0213 (not in BMP)";
452     &test("$nkf -W --oc=euc-jisx0213",$example{'test_data/jisx0213nonbmp.ans'},$example{'test_data/jisx0213nonbmp'});
453
454 # test_data/jisx0213needx0213_f
455
456 $example{'test_data/jisx0213needx0213_f'} = unpack('u',<<'eofeof');
457 MXH*LPKS#B<.?P['%C<6"Q)C$C<6OR:[%B\63RJ+)FLN0RZ;+GN*=O^*%M^*3
458 MFN.+DN.+G^*8GO"@@(OE@(+EA(OCDYOEC:'EC:/EEH;OJ+CEG+/EHJGEI9WE
459 MB9WFD[?FF8CFFJ#FGKOFH;+CKK;GI(#OJ8WGIKCOJ97GKYGGL:WGM9SGN8?H
460 M@+?PIJN_Z(VBZ(ZGZ(^1Z)2CZ)F;Z)FLZ*"?[ZFA[ZFB[ZFD\*B)M^F"F>F$
461 ME>F$I^>J@N>JN>>MI.>ML^>OL.>RIN>SM>2+G>>VI^>ZD>>]DO"CM([H@([P
462 MIIJPZ(2>\*:CG>B)B^^IG>B*M.B.E.B0C^B1O.B4F^B5D?"FO[;HF:_HFZ;H
463 MG+KHG;+HH(OPIYB4Z*.2Z*6%Y)JAZ*BUY)R,\*>NOO"GMJ#HM(GHN:SDH8[H
464 MOK;HO['I@K#IA8;IA9GIB9'PJ*:(Z8N&Z8N[Z8V:Z9")Z96XZ9J]Z9N:Z9Z6
465 MZ:"EZ:*\Z:.QZ:6`Z:B@Z:BQZ:NE\*FXO>FOKO"INZGIL:GPJH":Z;:9Z;B"
466 -\**(F/"JE['PJIJR"@``
467 eofeof
468
469 $example{'test_data/jisx0213needx0213_f.ans'} = unpack('u',<<'eofeof');
470 MJ:&ILZG`J=6IYZG^JJZJOJK,JM6JZZKZJZJKO:O#J]6KX:OQK*JLO*S+K-VL
471 MZJW^KJ*NO*[,KMNN[Z[PKZJOMJ_%K]^OZ:_^]:3UN/7$]=CUX_7^^:WYM/G$
472 M^='YYOGP^J3ZM/K(^MWZ[?KY^Z'[MOO.^]+[Y_OY_*_\N/S)_-W\[/SPC_.M
473 MC_.TC_/.C_/1C_/CC_/VC_2HC_2[C_3$C_3>C_3JC_3UC_6EC_6ZC_7!C_76
474 MC_7KC_7TC_:BC_:WC_;!C_;2C_;FC_;PC_>AC_>[C_?.C_?:C_?BC_?\C_BJ
475 MC_BSC_C`C_C.C_C8C_CKC_CYC_FOC_FSC_G/C_G<C_GJC_GTC_JHC_J^C_K!
476 MC_K=C_KFC_KVC_NDC_NQC_O%C_O2C_OOC_OSC_RDC_R\C_S&C_S2C_SDC_S^
477 EC_VAC_VTC_W,C_W8C_WMC_WVC_ZKC_Z\C_[-C_[3C_[NC_[V"@``
478 eofeof
479
480 printf "%-40s",  "test_data/jisx0213needx0213_f    ";
481     &test("$nkf -W --oc=euc-jisx0213",$example{'test_data/jisx0213needx0213_f'},$example{'test_data/jisx0213needx0213_f.ans'});
482
483 # test_data/shift_jisx0213-utf8-need-no-cp932
484
485 $example{'test_data/shift_jisx0213-utf8-need-no-cp932'} = unpack('u',<<'eofeof');
486 M[4#M3NU/[5/M7NU?[6;M;>UO[7#M=^U][7[MA.V-[8_MGNV?[:OMKNVO[;[M
487 MO^W"[<[MS^W0[=[MW^WL[>[M[^W[[?SN1>Y.[D_N4>Y>[E_N;>YO[GWN?NZ'
488 F[HWNC^Z0[I[NG^ZF[J[NK^ZV[K_NQ^[.[L_NT.[?[NSN[^[[[OP`
489 eofeof
490
491 $example{'test_data/shift_jisx0213-utf8-need-no-cp932.ans'} = unpack('u',<<'eofeof');
492 MYZ&#YZ2<YZ2N[ZF-[ZF2[ZF3\*6=L>>HN>>IK>^IE>>KJ^>MCN>MH.^IEN2)
493 MI.>QF>>TL>>U@>>WH^>XB.>XD>>_G^>_K.^IF^B%H.B%I^B%J.B*H^B*I.B,
494 MHNB,NNB-@^B/A^B/C^B0BNB2M.B2NNB3@NB6HNB6L.B9F^B9HNB>K>B>M>B@
495 MG^BCM>^IH.BDF.BHE>BHHNBIN>^IH^BMAN^II.BWCO"HB;?HO93PJ(^-Z+ZF
496 /Z8*^Z82BZ82OZ8>[Z8>D
497 eofeof
498
499 printf "%-40s",  "test_data/shift_jisx0213-utf8-need-no-cp932    ";
500     &test("$nkf --ic=shift_jisx0213 -w",$example{'test_data/shift_jisx0213-utf8-need-no-cp932'},$example{'test_data/shift_jisx0213-utf8-need-no-cp932.ans'});
501
502 # jisx0213conflict-ibmext
503 $example{'shift_jisx0213conflict-ibmext'} = "\x87\x40\xed\x40\xee\xf6\xfa\x52\xfb\x45\xfb\xfc\xfc\x4b";
504 $example{'shift_jisx0213conflict-ibmext.x0213utf8'} = "\xe2\x91\xa0\xe7\xa1\x83\xe9\x86\x9e\xe8\xb4\x89\xe9\x8c\x8d\xe9\xa8\xa0\xf0\xa9\xa9\xb2";
505 $example{'shift_jisx0213conflict-ibmext.cp932utf8'} = "\xe2\x91\xa0\xe7\xba\x8a\xe2\x85\xb7\xe2\x85\xa8\xe6\xb7\xbc\xe9\xab\x99\xe9\xbb\x91";
506
507 printf "%-40s",  "Shift_JISX0213 to UTF-8 (ibmext etc)";
508     &test("$nkf --ic=shift_jisx0213 -w",
509     $example{'shift_jisx0213conflict-ibmext'},
510     $example{'shift_jisx0213conflict-ibmext.x0213utf8'});
511
512 printf "%-40s",  "CP932 to UTF-8 (ibmext etc)";
513     &test("$nkf --ic=cp932 -w",
514     $example{'shift_jisx0213conflict-ibmext'},
515     $example{'shift_jisx0213conflict-ibmext.cp932utf8'});
516
517 printf "%-40s",  "UTF-8 to Shift_JISX0213 (ibmext etc)";
518     &test("$nkf --oc=shift_jisx0213 -W",
519     $example{'shift_jisx0213conflict-ibmext.x0213utf8'},
520     $example{'shift_jisx0213conflict-ibmext'});
521
522 printf "%-40s",  "UTF-8 to CP932 (ibmext etc)";
523     &test("$nkf --oc=cp932 -W --cp932inv",
524     $example{'shift_jisx0213conflict-ibmext.cp932utf8'},
525     "\x87\x40\xfa\x5c\xfa\x47\x87\x5c\xfb\x45\xfb\xfc\xfc\x4b");
526 # test_data/jisx0213utf8comb
527
528 $example{'test_data/jisx0213utf8comb'} = unpack('u',<<'eofeof');
529 MI/>D^*3YI/JD^Z7WI?BE^:7ZI?NE_*7]I?ZF^*O$J\BKR:O*J\NKS*O-J\ZK
530 .SZOEJ^:KVJO<J^"KY`H`
531 eofeof
532
533 $example{'test_data/jisx0213utf8comb.ans'} = unpack('u',<<'eofeof');
534 MXX&+XX*:XX&-XX*:XX&/XX*:XX&1XX*:XX&3XX*:XX*KXX*:XX*MXX*:XX*O
535 MXX*:XX*QXX*:XX*SXX*:XX*[XX*:XX.$XX*:XX.(XX*:XX>WXX*:PZ;,@,F4
536 MS(#)E,R!RHS,@,J,S(')F<R`R9G,@<F:S(#)FLR!RZG+I<NERZG,@<R`RZ7+
537 "J0H`
538 eofeof
539
540 $example{'test_data/jisx0213utf8combr.ans'} = unpack('u',<<'eofeof');
541 MI/>D^*3YI/JD^Z7WI?BE^:7ZI?NE_*7]I?ZF^*O$J\BKR:O*J\NKS*O-J\ZK
542 ,SZOEJ^:KVJO<J^8*
543 eofeof
544
545 printf "%-40s",  "EUC-JISX0213 to UTF-8 (combining)";
546     &test("$nkf --ic=euc-jisx0213 -w",$example{'test_data/jisx0213utf8comb'},$example{'test_data/jisx0213utf8comb.ans'});
547 printf "%-40s",  "UTF-8 to EUC-JISX0213 (combining)";
548     &test("$nkf -W --oc=euc-jisx0213",$example{'test_data/jisx0213utf8comb.ans'},$example{'test_data/jisx0213utf8combr.ans'});
549
550 # test_data/jisx0213comb
551
552 $example{'test_data/jisx0213comb'} = unpack('u',<<'eofeof');
553 MXX&+XX*:XX&-XX*:XX&/XX*:XX&1XX*:XX&3XX*:XX*KXX*:XX*MXX*:XX*O
554 MXX*:XX*QXX*:XX*SXX*:XX*[XX*:XX.$XX*:XX.(XX*:XX>WXX*:PZ;,@,F4
555 MS(#)E,R!RHS,@,J,S(')F<R`R9G,@<F:S(#)FLR!RZG+I<NERZG,@<R`RZ7+
556 "J0H`
557 eofeof
558
559 $example{'test_data/jisx0213comb.ans'} = unpack('u',<<'eofeof');
560 M,$LPFC!-,)HP3S":,%$PFC!3,)HPJS":,*TPFC"O,)HPL3":,+,PFC"[,)HP
561 MQ#":,,@PFC'W,)H`Y@,``E0#``)4`P$"C`,``HP#`0)9`P`"60,!`EH#``):
562 4`P$"Z0+E`N4"Z0,!`P`"Y0+I``H`
563 eofeof
564
565 printf "%-40s",  "UTF-8 to UTF-16BE (combining)";
566     &test("$nkf -W --oc=utf-16be",$example{'test_data/jisx0213comb'},$example{'test_data/jisx0213comb.ans'});
567 printf "%-40s",  "UTF-16BE to UTF-8 (combining)";
568     &test("$nkf --ic=utf-16be -w",$example{'test_data/jisx0213comb.ans'},$example{'test_data/jisx0213comb'});
569
570 printf "%-40s", "UTF-32BE to EUC-JISX0213 (w/o comb char)";
571     &test("$nkf --ic=UTF-32BE --oc=euc-jisx0213",h("000030AB"),h("A5AB"));
572 printf "%-40s", "UTF-16LE to EUC-JISX0213 (w/o comb char)";
573     &test("$nkf --ic=utf-16le --oc=euc-jisx0213",h("AB30"),h("A5AB"));
574 printf "%-40s", "UTF-8 to EUC-JISX0213 (w/o comb char)";
575     &test("$nkf --ic=utf-8 --oc=euc-jisx0213",h("E382AB"),h("A5AB"));
576
577 # test_data/no_best_fit_chars
578
579 $example{'test_data/no_best_fit_chars'} = unpack('u',<<'eofeof');
580 ;XH"5XHBE[[R-[[^@[[^A[[^B[[^C[[^D[[^E
581 eofeof
582
583 printf "%-40s", "no_best_fit_chars (eucJP-ascii)";
584     &test("$nkf -W --oc=eucJP-ascii --no-best-fit-chars",$example{'test_data/no_best_fit_chars'},'');
585
586 $example{'test_data/no_best_fit_chars_ms'} = unpack('u',<<'eofeof');
587 9PJ+"H\*EPJ;"K.*`E.*`EN*`ON*(DN.`G```
588 eofeof
589
590 printf "%-40s", "no_best_fit_chars (eucJP-ms)";
591     &test("$nkf -W --oc=eucJP-ms --no-best-fit-chars",$example{'test_data/no_best_fit_chars_ms'},'');
592
593 $example{'test_data/no_best_fit_chars_cp932'} = unpack('u',<<'eofeof');
594 MPJ'"HL*CPJ7"IL*IPJK"J\*LPJW"KL*OPK+"L\*UPK?"N,*YPKK"N\.`PX'#
595 M@L.#PX3#A<.&PX?#B,.)PXK#B\.,PXW#CL./PY##D<.2PY/#E,.5PY;#F,.9
596 MPYK#F\.<PYW#GL.?PZ##H<.BPZ/#I,.EPZ;#I\.HPZG#JL.KPZS#K<.NPZ_#
597 @L,.QP[+#L\.TP[7#ML.XP[G#NL.[P[S#O<.^P[_C@I0`
598 eofeof
599
600 printf "%-40s", "no_best_fit_chars (cp932)";
601     &test("$nkf -W --oc=CP932 --no-best-fit-chars",$example{'test_data/no_best_fit_chars_cp932'},'');
602 # test_data/irv
603
604 # $example{'test_data/irv'} = unpack('u',<<'eofeof');
605 # %#B`/(!L`
606 # eofeof
607
608 # $example{'test_data/irv.ans'} = unpack('u',<<'eofeof');
609 # %#B`/(!L`
610 # eofeof
611
612 # printf "%-40s", "test_data/irv";
613 #    &test("$nkf -wE",$example{'test_data/irv'},$example{'test_data/irv.ans'});
614
615
616 # UCS Mapping Test
617 print "\nUCS Mapping Test\n\n";
618
619 print "Shift_JIS to UTF-16\n";
620 $example{'ms_ucs_map_1_sjis'} = "\x81\x60\x81\x61\x81\x7C\x81\x91\x81\x92\x81\xCA";
621 $example{'ms_ucs_map_1_utf16'} = "\x30\x1C\x20\x16\x22\x12\x00\xA2\x00\xA3\x00\xAC";
622 $example{'ms_ucs_map_1_utf16_ms'} = "\xFF\x5E\x22\x25\xFF\x0D\xFF\xE0\xFF\xE1\xFF\xE2";
623
624 printf "%-40s", "Normal UCS Mapping :";
625     &test("$nkf -w16B0 --ic=Shift_JIS",$example{'ms_ucs_map_1_sjis'},$example{'ms_ucs_map_1_utf16'});
626
627 printf "%-40s", "Microsoft UCS Mapping :";
628     &test("$nkf -w16B0 -S --ms-ucs-map",$example{'ms_ucs_map_1_sjis'},$example{'ms_ucs_map_1_utf16_ms'});
629 printf "%-40s", "CP932 to UTF-16BE :";
630     &test("$nkf --ic=cp932 --oc=utf-16be",$example{'ms_ucs_map_1_sjis'},$example{'ms_ucs_map_1_utf16_ms'});
631
632 # X0201 仮名
633 # X0201->X0208 conversion
634 # X0208 aphabet -> ASCII
635 # X0201 相互変換
636
637 print "\nX0201 test\n\n";
638
639 $example{'x0201.sjis'} = unpack('u',<<'eofeof');
640 MD5.*<(-*@TR#3H-0@U*#2X--@T^#48-3"I%3B7""8()A@F*"8X)D@F6"9H*!
641 M@H*"@X*$@H6"AH*'"I%3BTR-AH%)@9>!E(&0@9.!3X&5@9:!:8%J@7R!>X&!
642 M@6V!;H%O@7"!CPJ4O(IPMK>X/;FZMMZWWKC>N=ZZWH+&"I2\BG#*W\O?S-_-
643 MW\[?M]^QW@K*W\O?S`IH86YK86MU(,K?R]_,I`K*W\O?S-VA"I2\BG""S(SC
644 !"@!"
645 eofeof
646
647 $example{'x0201.euc'} = unpack('u',<<'eofeof');
648 MP;2ST:6KI:VEKZ6QI;.EK*6NI;"ELJ6T"L&TL=&CP:/"H\.CQ*/%H\:CQZ/A
649 MH^*CXZ/DH^6CYJ/G"L&TM:VYYJ&JH?>A]*'PH?.AL*'UH?:ARJ'+H=VAW*'A
650 MH<ZASZ'0H=&A[PK(OK/1CK:.MXZX/8ZYCKJ.MH[>CK>.WHZXCMZ.N8[>CKJ.
651 MWJ3("LB^L]&.RH[?CLN.WX[,CM^.S8[?CLZ.WXZWCM^.L8[>"H[*CM^.RX[?
652 MCLP*:&%N:V%K=2".RH[?CLN.WX[,CJ0*CLJ.WX[+CM^.S([=CJ$*R+ZST:3.
653 #N.4*
654 eofeof
655
656 $example{'x0201.utf'} = unpack('u',<<'eofeof');
657 MY86HZ*>2XX*KXX*MXX*OXX*QXX*SXX*LXX*NXX*PXX*RXX*T"N6%J.B+L>^\
658 MH>^\HN^\H^^\I.^\I>^\IN^\I^^]@>^]@N^]@^^]A.^]A>^]AN^]APKEA:CH
659 MJ)CEC[?OO('OO*#OO(/OO(3OO(7OO+[OO(;OO(KOO(COO(GBB)+OO(OOO)WO
660 MO+OOO+WOO9OOO9W"I0KEC8KHIY+OO;;OO;?OO;@][[VY[[VZ[[VV[[Z>[[VW
661 M[[Z>[[VX[[Z>[[VY[[Z>[[VZ[[Z>XX&H"N6-BNBGDN^^BN^^G^^^B^^^G^^^
662 MC.^^G^^^C>^^G^^^CN^^G^^]M^^^G^^]L>^^G@KOOHKOOI_OOHOOOI_OOHP*
663 M:&%N:V%K=2#OOHKOOI_OOHOOOI_OOHSOO:0*[[Z*[[Z?[[Z+[[Z?[[Z,[[Z=
664 1[[VA"N6-BNBGDN.!KN6^C`H`
665 eofeof
666
667 $example{'x0201.jis'} = unpack('u',<<'eofeof');
668 M&R1"030S424K)2TE+R4Q)3,E+"4N)3`E,B4T&RA""ALD0D$T,5$C02-"(T,C
669 M1"-%(T8C1R-A(V(C8R-D(V4C9B-G&RA""ALD0D$T-2TY9B$J(7<A="%P(7,A
670 M,"%U(78A2B%+(5TA7"%A(4XA3R%0(5$A;QLH0@H;)$)(/C-1&RA)-C<X&RA"
671 M/1LH23DZ-EXW7CA>.5XZ7ALD0B1(&RA""ALD0D@^,U$;*$E*7TM?3%]-7TY?
672 M-U\Q7ALH0@H;*$E*7TM?3!LH0@IH86YK86MU(!LH24I?2U],)!LH0@H;*$E*
673 97TM?3%TA&RA""ALD0D@^,U$D3CAE&RA""@``
674 eofeof
675
676 $example{'x0201.sosi'} = unpack('u',<<'eofeof');
677 M&R1"030S424K)2TE+R4Q)3,E+"4N)3`E,B4T&RA*"ALD0D$T,5$C02-"(T,C
678 M1"-%(T8C1R-A(V(C8R-D(V4C9B-G&RA*"ALD0D$T-2TY9B$J(7<A="%P(7,A
679 M,"%U(78A2B%+(5TA7"%A(4XA3R%0(5$A;QLH2@H;)$)(/C-1&RA*#C8W.`\;
680 M*$H]#CDZ-EXW7CA>.5XZ7@\;)$(D2!LH2@H;)$)(/C-1&RA*#DI?2U],7TU?
681 M3E\W7S%>#PH.2E]+7TP/&RA*"FAA;FMA:W4@#DI?2U],)`\;*$H*#DI?2U],
682 672$/&RA*"ALD0D@^,U$D3CAE&RA""@``
683 eofeof
684
685 $example{'x0201.x0208'} = unpack('u',<<'eofeof');
686 M&R1"030S424K)2TE+R4Q)3,E+"4N)3`E,B4T&RA""ALD0D$T,5$;*$)!0D-$
687 M149'86)C9&5F9PH;)$)!-#4M.68;*$(A0",D)5XF*B@I+2L]6UU[?1LD0B%O
688 M&RA""ALD0D@^,U$E*R4M)2\;*$(]&R1")3$E,R4L)2XE,"4R)30D2!LH0@H;
689 M)$)(/C-1)5$E5"57)5HE724M(2PE(B$K&RA""ALD0B51)50E51LH0@IH86YK
690 M86MU(!LD0B51)50E52$B&RA""ALD0B51)50E525S(2,;*$(*&R1"2#XS421.
691 &.&4;*$(*
692 eofeof
693
694 # -X is necessary to allow X0201 in SJIS
695 # -Z convert X0208 alphabet to ASCII
696 printf "%-40s", "X0201 conversion: SJIS";
697     &test("$nkf -jXZ",$example{'x0201.sjis'},$example{'x0201.x0208'});
698 printf "%-40s", "X0201 conversion: JIS";
699     &test("$nkf -jZ",$example{'x0201.jis'},$example{'x0201.x0208'});
700 printf "%-40s", "X0201 conversion: SI/SO";
701     &test("$nkf -jZ",$example{'x0201.sosi'},$example{'x0201.x0208'});
702 printf "%-40s", "X0201 conversion: EUC";
703     &test("$nkf -jZ",$example{'x0201.euc'},$example{'x0201.x0208'});
704 printf "%-40s", "X0201 conversion: UTF8";
705     &test("$nkf -jZ",$example{'x0201.utf'},$example{'x0201.x0208'});
706 printf "%-40s", "-wZ"; &test("$nkf -wZ",
707         "\xE3\x80\x80\xEF\xBD\x81\xEF\xBC\xA1&\xE3\x82\xA2",
708         "\xE3\x80\x80aA&\xE3\x82\xA2");
709 printf "%-40s", "-wZ0"; &test("$nkf -wZ0",
710         "\xE3\x80\x80\xEF\xBD\x81\xEF\xBC\xA1&\xE3\x82\xA2",
711         "\xE3\x80\x80aA&\xE3\x82\xA2");
712 printf "%-40s", "-wZ1"; &test("$nkf -wZ1",
713         "\xE3\x80\x80\xEF\xBD\x81\xEF\xBC\xA1&\xE3\x82\xA2",
714         " aA&\xE3\x82\xA2");
715 printf "%-40s", "-wZ2"; &test("$nkf -wZ2",
716         "\xE3\x80\x80\xEF\xBD\x81\xEF\xBC\xA1&\xE3\x82\xA2",
717         "  aA&\xE3\x82\xA2");
718 printf "%-40s", "-wZ3"; &test("$nkf -wZ3",
719         "\xE3\x80\x80\xEF\xBD\x81\xEF\xBC\xA1&\xE3\x82\xA2",
720         "\xE3\x80\x80aA&amp;\xE3\x82\xA2");
721 printf "%-40s", "-wZ4"; &test("$nkf -wZ4",
722         "\xE3\x80\x80\xEF\xBD\x81\xEF\xBC\xA1&\xE3\x82\xA2",
723         "\xE3\x80\x80aA&\xEF\xBD\xB1");
724 # -x means X0201 output
725 printf "%-40s", "X0201 output: SJIS";
726     &test("$nkf -xs",$example{'x0201.euc'},$example{'x0201.sjis'});
727 printf "%-40s", "X0201 output: JIS";
728     &test("$nkf -xj",$example{'x0201.sjis'},$example{'x0201.jis'});
729 printf "%-40s", "X0201 output: EUC";
730     &test("$nkf -xe",$example{'x0201.jis'},$example{'x0201.euc'});
731 printf "%-40s", "X0201 output: UTF8";
732     &test("$nkf -xw",$example{'x0201.jis'},$example{'x0201.utf'});
733 # test_data/x0201jis=
734
735 $example{'test_data/x0201jis=.ans'} = unpack('u',<<'eofeof');
736 MH:*CI*6FIZBIJJNLK:ZOL+&RL[2UMK>XN;J[O+V^O\#!PL/$Q<;'R,G*R\S-
737 2SL_0T=+3U-76U]C9VMO<W=[?
738 eofeof
739
740 printf "%-40s",  "X0201 JIS contains '='";
741     &test("$nkf -xs",
742     "\x1b(I!\"#\$%&'()*+,-./0123456789:;<=>?\@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_\x1b(B",
743     $example{'test_data/x0201jis=.ans'});
744 # test_data/Xx0213
745
746 $example{'test_data/Xx0213'} = unpack('u',<<'eofeof');
747 M[[VV[[Z?[[VW[[Z?[[VX[[Z?[[VY[[Z?[[VZ[[Z?[[V^[[Z?[[Z"[[Z?[[Z$
748 *[[Z?XX>WXX*:"@``
749 eofeof
750
751 $example{'test_data/Xx0213.ans'} = unpack('u',<<'eofeof');
752 3I?>E^*7YI?JE^Z7\I?VE_J;X"@``
753 eofeof
754
755 printf "%-40s",  "test_data/Xx0213    ";
756     &test("$nkf -X -W --oc=euc-jisx0213",$example{'test_data/Xx0213'},$example{'test_data/Xx0213.ans'});
757 # test_data/xx0213
758
759 $example{'test_data/xx0213'} = unpack('u',<<'eofeof');
760 M[[VV[[Z?[[VW[[Z?[[VX[[Z?[[VY[[Z?[[VZ[[Z?[[V^[[Z?[[Z"[[Z?[[Z$
761 *[[Z?XX>WXX*:"@``
762 eofeof
763
764 $example{'test_data/xx0213.ans'} = unpack('u',<<'eofeof');
765 CCK:.WXZWCM^.N([?CKF.WXZZCM^.OH[?CL*.WX[$CM^F^`H`
766 eofeof
767
768 printf "%-40s",  "test_data/xx0213    ";
769     &test("$nkf -x -W --oc=euc-jisx0213",$example{'test_data/xx0213'},$example{'test_data/xx0213.ans'});
770 # test_data/Z4x0213
771
772 $example{'test_data/Z4x0213'} = unpack('u',<<'eofeof');
773 3I?>E^*7YI?JE^Z7\I?VE_J;X"@``
774 eofeof
775
776 $example{'test_data/Z4x0213.ans'} = unpack('u',<<'eofeof');
777 M[[VV[[Z?[[VW[[Z?[[VX[[Z?[[VY[[Z?[[VZ[[Z?[[V^[[Z?[[Z"[[Z?[[Z$
778 *[[Z?XX>WXX*:"@``
779 eofeof
780
781 printf "%-40s",  "test_data/Z4x0213    ";
782     &test("$nkf -Z4 --ic=euc-jisx0213 -w",$example{'test_data/Z4x0213'},$example{'test_data/Z4x0213.ans'});
783 # test_data/Z4comb
784
785 $example{'test_data/Z4comb'} = unpack('u',<<'eofeof');
786 MXX""XX",XX"-XX"!XX.[XX.\XX*;XX*<XX*AXX*BXX*CXX*DXX*EXX*FXX*G
787 MXX*HXX*IXX*JXX*KXX*LXX*MXX*NXX*OXX*PXX*QXX*RXX*SXX*TXX*UXX*V
788 MXX*WXX*XXX*YXX*ZXX*[XX*\XX*]XX*^XX*_XX.`XX.!XX."XX.#XX.$XX.%
789 MXX.&XX.'XX.(XX.)XX.*XX.+XX.,XX.-XX..XX./XX.0XX.1XX.2XX.3XX.4
790 MXX.5XX.6XX.7XX.8XX.9XX.:XX.;XX.<XX.=XX.>XX.?XX.@XX.AXX.BXX.C
791 MXX.DXX.EXX.FXX.GXX.HXX.IXX.JXX.KXX.LXX.MXX.OXX.RXX.SXX.TXX*K
792 MXX*:XX*MXX*:XX*OXX*:XX*QXX*:XX*SXX*:XX*[XX*:XX.$XX*:XX.(XX*:
793 -XX>WXX*:XX*BXX*9"@``
794 eofeof
795
796 $example{'test_data/Z4comb.ans'} = unpack('u',<<'eofeof');
797 MCJ&.HHZCCJ2.I8ZPCMZ.WXZGCK&.J(ZRCJF.LXZJCK2.JXZUCK:.MH[>CK>.
798 MMX[>CKB.N([>CKF.N8[>CKJ.NH[>CKN.NX[>CKR.O([>CKV.O8[>CKZ.OH[>
799 MCK^.OX[>CL".P([>CL&.P8[>CJ^.PH["CMZ.PX[#CMZ.Q([$CMZ.Q8[&CL>.
800 MR([)CLJ.RH[>CLJ.WX[+CLN.WH[+CM^.S([,CMZ.S([?CLV.S8[>CLV.WX[.
801 MCLZ.WH[.CM^.SX[0CM&.TH[3CJR.U(ZMCM6.KH[6CM>.V([9CMJ.VX[<CJ:.
802 LW8ZSCMZ.MH[?CK>.WXZXCM^.N8[?CKJ.WXZ^CM^.PH[?CL2.WZ;XCK&.W@H`
803 eofeof
804
805 printf "%-40s",  "test_data/Z4comb    ";
806     &test("$nkf -Z4 -W --oc=euc-jisx0213",$example{'test_data/Z4comb'},$example{'test_data/Z4comb.ans'});
807
808 # MIME decode
809
810 print "\nMIME test\n\n";
811
812 # MIME ISO-2022-JP
813
814 $example{'mime.iso2022'} = unpack('u',<<'eofeof');
815 M/3])4T\M,C`R,BU*4#]"/T=Y4D%.144W96E23TI566Q/4U9)1WEH2S\]"CT_
816 M:7-O+3(P,C(M2E`_0C]'>5)!3D5%-V5I4D]*55EL3U-624=Y:$L_/0H]/VES
817 M;RTR,#(R+4I0/U$_/3%")$(D1B11/3%"*$)?96YD/ST*&R1`)#TD)B0K)$H;
818 M*$H@/3])4T\M,C`R,BU*4#]"/T=Y4D%.144W96E23U!Y:S=D:'-O4V<]/3\]
819 M(&5N9"!O9B!L:6YE"CT_25-/+3(P,C(M2E`_0C]'>5)!3D5%-V5I4D]0>6LW
820 M9&AS;U-G/3T_/2`]/TE33RTR,#(R+4I0/T(_1WE204Y%13=E:5)/4'EK-V1H
821 M<V]39ST]/ST*0G)O:V5N(&-A<V4*/3])4T\M,C`R,BU*4#]"/T=Y4D%.144W
822 M96E23U!Y:S=D"FAS;U-G/3T_/2`]/TE33RTR,`HR,BU*4#]"/T=Y4D%.144W
823 M96E23U!Y:S=D:'-O4V<]/3\]"CT_25-/+3(P,C(M2E`_0C]'>5)!3D5%-V5I
824 44D]*55EL3QM;2U-624=Y:$L_/0H_
825 eofeof
826
827 $example{'mime.ans.strict'} = unpack('u',<<'eofeof');
828 M&R1"-$$[>B1.)48E.25(&RA""ALD0C1!.WHD3B5&)3DE2!LH0@H;)$(D1B11
829 M&RA"(&5N9`H;)$(D/20F)"LD2ALH0B`;)$(T03MZ)$X_*3MV&RA"96YD(&]F
830 M(&QI;F4*&R1"-$$[>B1./RD[=C1!.WHD3C\I.W8;*$(*0G)O:V5N(&-A<V4*
831 M/3])4T\M,C`R,BU*4#]"/T=Y4D%.144W96E23U!Y:S=D"FAS;U-G/3T_/2`]
832 M/TE33RTR,`HR,BU*4#]"/T=Y4D%.144W96E23U!Y:S=D:'-O4V<]/3\]"CT_
833 L25-/+3(P,C(M2E`_0C]'>5)!3D5%-V5I4D]*55EL3QM;2U-624=Y:$L_/0H_
834 eofeof
835
836 $example{'mime.unbuf.strict'} = unpack('u',<<'eofeof');
837 M&R1"-$$[>B1.)48E.25(&RA""ALD0C1!.WHD3B5&)3DE2!LH0@H;)$(D1B11
838 M&RA"(&5N9`H;)$(D/20F)"LD2ALH0B`;)$(T03MZ)$X_*3MV&RA"96YD(&]F
839 M(&QI;F4*&R1"-$$[>B1./RD[=C1!.WHD3C\I.W8;*$(*0G)O:V5N(&-A<V4*
840 M&R1"-$$[>B1./RD;*$)H<V]39ST]/ST@/3])4T\M,C`*,C(M2E`_0C]'>5)!
841 M3D5%-V5I4D]0>6LW9&AS;U-G/3T_/0H;)$(T03MZ)$XE1ALH0EM+4U9)1WEH
842 $2S\]"F5I
843 eofeof
844
845 $example{'mime.ans'} = unpack('u',<<'eofeof');
846 M&R1"-$$[>B1.)48E.25(&RA""ALD0C1!.WHD3B5&)3DE2!LH0@H;)$(D1B11
847 M&RA"(&5N9`H;)$(D/20F)"LD2ALH0B`;)$(T03MZ)$X_*3MV&RA"96YD(&]F
848 M(&QI;F4*&R1"-$$[>B1./RD[=C1!.WHD3C\I.W8;*$(*0G)O:V5N(&-A<V4*
849 M&R1"-$$[>B1./RD;*$)H<V]39ST]/ST@&R1"-$$[>B1./RD[=ALH0@H;)$(T
850 603MZ)$XE1ALH0EM+4U9)1WEH2S\]"@`*
851 eofeof
852
853 $example{'mime.unbuf'} = unpack('u',<<'eofeof');
854 M&R1"-$$[>B1.)48E.25(&RA""ALD0C1!.WHD3B5&)3DE2!LH0@H;)$(D1B11
855 M&RA"(&5N9`H;)$(D/20F)"LD2ALH0B`;)$(T03MZ)$X_*3MV&RA"96YD(&]F
856 M(&QI;F4*&R1"-$$[>B1./RD[=C1!.WHD3C\I.W8;*$(*0G)O:V5N(&-A<V4*
857 M&R1"-$$[>B1./RD;*$)H<V]39ST]/ST@&R1"-$$[>B1./RD[=ALH0@H;)$(T
858 603MZ)$XE1ALH0EM+4U9)1WEH2S\]"@`*
859 eofeof
860
861 $example{'mime.base64'} = unpack('u',<<'eofeof');
862 M9W-M5"])3&YG<FU#>$I+-&=Q=4,S24LS9W%Q0E%:3TUI-39,,S0Q-&=S5T)1
863 M43!+9VUA1%9O3T@*9S)+1%1O3'=K8C)1;$E+;V=Q2T-X24MG9W5M0W%*3EEG
864 <<T=#>$E+9V=U;4,X64Q&9W)70S592VMG<6U""F=Q
865 eofeof
866
867 $example{'mime.base64.ans'} = unpack('u',<<'eofeof');
868 M&R1")$M&?B1I)#LD1D0Z)"TD7B0Y)"PA(D5L-7XV83E9)$<A(ALH0@T*&R1"
869 M(T<E-R5G)4,E+R1R0C\_="0J)"0D1B0B)&LD*D4Y)$,D1B0B)&LD<R1')#<D
870 (9R0F)"L;*$(E
871 eofeof
872
873 # printf "%-40s", "Next test is expected to Fail.\n";
874 printf "%-40s", "MIME decode (strict)";
875     $tmp = &test("$nkf -jmS",$example{'mime.iso2022'},$example{'mime.ans.strict'});
876
877 $example{'mime.ans.alt'} = unpack('u',<<'eofeof');
878 M&R1"-$$[>B1.)48E.25(&RA""ALD0C1!.WHD3B5&)3DE2!LH0@H;)$(D1B11
879 M&RA"96YD"ALD0B0])"8D*R1*&RA"&R1"-$$[>B1./RD[=ALH0F5N9&]F;&EN
880 M90H;)$(T03MZ)$X_*3MV-$$[>B1./RD[=ALH0@I"<F]K96YC87-E"ALD0C1!
881 H.WHD3C\I.W8T03MZ)$X_*3MV&RA""ALD0C1!.WHD3B5&)3DE)!LH0@``
882 eofeof
883
884 $example{'mime.unbuf.alt'} = unpack('u',<<'eofeof');
885 M&R1"-$$[>B1.)48E.25(&RA""ALD0C1!.WHD3B5&)3DE2!LH0@H;)$(D1B11
886 M&RA"96YD"ALD0B0])"8D*R1*&RA"&R1"-$$[>B1./RD[=ALH0F5N9&]F;&EN
887 M90H;)$(T03MZ)$X_*3MV-$$[>B1./RD[=ALH0@I"<F]K96YC87-E"ALD0C1!
888 H.WHD3C\I.W8T03MZ)$X_*3MV&RA""ALD0C1!.WHD3B5&)3DE)!LH0@``
889 eofeof
890
891 printf "%-40s", "MIME decode (nonstrict)";
892     $tmp = &test("$nkf -jmN",$example{'mime.iso2022'},$example{'mime.ans'},$example{'mime.ans.alt'});
893     # open(OUT,">tmp1");printf "%-40s", OUT pack('u',$tmp);close(OUT);
894 # unbuf mode implies more pessimistic decode
895 printf "%-40s", "MIME decode (unbuf)";
896     $tmp = &test("$nkf -jmNu",$example{'mime.iso2022'},$example{'mime.unbuf'},$example{'mime.unbuf.alt'});
897     # open(OUT,">tmp2");printf "%-40s", OUT pack('u',$tmp);close(OUT);
898 printf "%-40s", "MIME decode (base64)";
899     &test("$nkf -jmB",$example{'mime.base64'},$example{'mime.base64.ans'});
900 #MIME BASE64 must be LF?
901
902 # MIME ISO-8859-1
903
904 $example{'mime.is8859'} = unpack('u',<<'eofeof');
905 M/3])4T\M.#@U.2TQ/U$_*CU#-V%V83\_/2`*4&5E<B!4]G)N9W)E;@I,87-S
906 M92!(:6QL97+X92!0971E<G-E;B`@7"`B36EN(&MA97!H97-T(&AA<B!F86%E
907 M="!E="!F;V5L(2(*06%R:'5S(%5N:79E<G-I='DL($1%3DU!4DL@(%P@(DUI
908 <;B!KYG!H97-T(&AA<B!FY65T(&5T(&;X;"$B"@!K
909 eofeof
910
911 $example{'mime.is8859.ans'} = unpack('u',<<'eofeof');
912 M*L=A=F$_(`I0965R(%3V<FYG<F5N"DQA<W-E($AI;&QE<OAE(%!E=&5R<V5N
913 M("!<(")-:6X@:V%E<&AE<W0@:&%R(&9A865T(&5T(&9O96PA(@I!87)H=7,@
914 M56YI=F5R<VET>2P@1$5.34%22R`@7"`B36EN(&OF<&AE<W0@:&%R(&;E970@
915 )970@9OAL(2(*
916 eofeof
917
918 # Without -l, ISO-8859-1 was handled as X0201.
919
920 printf "%-40s", "MIME ISO-8859-1 (Q)";
921     &test("$nkf -jml",$example{'mime.is8859'},$example{'mime.is8859.ans'});
922
923 # test for -f is not so simple.
924
925 print "\nBug Fixes\n\n";
926
927 # test_data/cr
928
929 $example{'test_data/cr'} = unpack('u',<<'eofeof');
930 1I,:DN:3(#71E<W0-=&5S=`T`
931 eofeof
932
933 $example{'test_data/cr.ans'} = unpack('u',<<'eofeof');
934 7&R1")$8D.21(&RA""G1E<W0*=&5S=`H`
935 eofeof
936
937 printf "%-40s", "test_data/cr";
938     &test("$nkf -jd",$example{'test_data/cr'},$example{'test_data/cr.ans'});
939 # test_data/fixed-qencode
940
941 $example{'test_data/fixed-qencode'} = unpack('u',<<'eofeof');
942 M("`@("`@("`],4(D0CYE/STS1#TQ0BA""B`@("`@("`@/3%")$(^93TS1CTS
943 '1#TQ0BA""@``
944 eofeof
945
946 $example{'test_data/fixed-qencode.ans'} = unpack('u',<<'eofeof');
947 F("`@("`@("`;)$(^93\]&RA""B`@("`@("`@&R1"/F4_/1LH0@H`
948 eofeof
949
950 printf "%-40s", "test_data/fixed-qencode";
951     &test("$nkf -jmQ",$example{'test_data/fixed-qencode'},$example{'test_data/fixed-qencode.ans'});
952 # test_data/long-fold-1
953
954 $example{'test_data/long-fold-1'} = unpack('u',<<'eofeof');
955 MI,JDK*2DI,JDK*2DI,JDK*'!I*2DKJ3GI*:DK*2BI.JDWJ2WI,:AHJ2SI.RD
956 M\J2]I,ZDWJ3>I**DQ*2KI*:DR*&BI,FDIJ3BI-^DT*2HI*RD[Z3KI*2DMZ&B
957 MI,BDP:3EI*:DQZ3!I.>D\Z2NI.RDZZ2KI.*DMZ3SI,JDI*&C"J2SI+.DSR!#
958 M4B],1B"DSKG4H:,-"J2SI+.DSR!#4B"DSKG4H:,-I+.DLZ3/($Q&+T-2(*3.
959 9N=2AHPH-"J2SI+.DSR!,1B"DSKG4H:,*"@``
960 eofeof
961
962 $example{'test_data/long-fold-1.ans'} = unpack('u',<<'eofeof');
963 M&R1")$HD+"0D)$HD+"0D)$HD+"%!)"0D+B1G)"8D+"0B)&HD7B0W)$8A(B0S
964 M)&PD<B0])$XD7B1>)"(D1"0K&RA""ALD0B0F)$@A(B1))"8D8B1?)%`D*"0L
965 M)&\D:R0D)#<A(B1()$$D920F)$<D021G)',D+B1L)&LD*R1B)#<D<QLH0@H;
966 M)$(D2B0D(2,;*$(*&R1")#,D,R1/&RA"($-2+TQ&(!LD0B1..50A(QLH0@H;
967 M)$(D,R0S)$\;*$(@0U(@&R1")$XY5"$C&RA""ALD0B0S)#,D3QLH0B!,1B]#
968 M4B`;)$(D3CE4(2,;*$(*"ALD0B0S)#,D3QLH0B!,1B`;)$(D3CE4(2,;*$(*
969 !"@``
970 eofeof
971
972 printf "%-40s", "test_data/long-fold-1";
973     &test("$nkf -jF60",$example{'test_data/long-fold-1'},$example{'test_data/long-fold-1.ans'});
974 # test_data/long-fold
975
976 $example{'test_data/long-fold'} = unpack('u',<<'eofeof');
977 MI,JDK*2DI,JDK*2DI,JDK*'!I*2DKJ3GI*:DK*2BI.JDWJ2WI,:AHJ2SI.RD
978 M\J2]I,ZDWJ3>I**DQ*2KI*:DR*&BI,FDIJ3BI-^DT*2HI*RD[Z3KI*2DMZ&B
979 MI,BDP:3EI*:DQZ3!I.>D\Z2NI.RDZZ2KI.*DMZ3SI,JDI*&C"J2SI+.DS\.[
980 'I*2YU*&C"@``
981 eofeof
982
983 $example{'test_data/long-fold.ans'} = unpack('u',<<'eofeof');
984 M&R1")$HD+"0D)$HD+"0D)$HD+"%!)"0D+B1G)"8D+"0B)&HD7B0W)$8A(B0S
985 M)&PD<B0])$XD7B1>)"(D1"0K&RA""ALD0B0F)$@A(B1))"8D8B1?)%`D*"0L
986 M)&\D:R0D)#<A(B1()$$D920F)$<D021G)',D+B1L)&LD*R1B)#<D<QLH0@H;
987 :)$(D2B0D(2,D,R0S)$]#.R0D.50A(QLH0@H`
988 eofeof
989
990 printf "%-40s", "test_data/long-fold";
991     &test("$nkf -jf60",$example{'test_data/long-fold'},$example{'test_data/long-fold.ans'});
992 # test_data/mime_out
993
994 $example{'test_data/mime_out'} = unpack('u',<<'eofeof');
995 M"BTM+2T*4W5B:F5C=#H@86%A82!A86%A(&%A86$@86%A82!A86%A(&%A86$@
996 M86%A82!A86%A(&%A86$@86%A82!A86%A(&%A86$@86%A82!A86%A"BTM+2T*
997 M4W5B:F5C=#H@I**DI*2FI*BDJJ2KI*VDKZ2QI+.DM:2WI+FDNZ2]I+^DP:3$
998 MI,:DR*3*I,NDS*3-I,ZDSZ32I-6DV*3;I-ZDWZ3@I.&DXJ3DI*2DYJ2HI.@*
999 M+2TM+0I3=6)J96-T.B!A86%A(&%A86$@86%A82!A86%A(&%A86$@86%A82!A
1000 I86%A(*2BI*2DIJ2HI*H@86%A82!A86%A(&%A86$@86%A80HM+2TM"@H`
1001 eofeof
1002
1003 $example{'test_data/mime_out.ans'} = unpack('u',<<'eofeof');
1004 M"BTM+2T*4W5B:F5C=#H@86%A82!A86%A(&%A86$@86%A82!A86%A(&%A86$@
1005 M86%A82!A86%A(&%A86$@86%A82!A86%A(&%A86$@86%A80H@86%A80HM+2TM
1006 M"E-U8FIE8W0Z(#T_25-/+3(P,C(M2E`_0C]'>5)#2D-):TI#46U*0V=K2VE1
1007 M<DI#,&M,>5%X2D1-:TY343-*1&MB2T5)/3\]"B`]/TE33RTR,#(R+4I0/T(_
1008 M1WE20TI$<VM04U$O2D5%:U)#4D=*16=K4VE23$I%=VM44U)/2D4X:U5I4E9*
1009 M1F=B2T5)/3\]"B`]/TE33RTR,#(R+4I0/T(_1WE20TI&<VM8:5)F2D=!:UE3
1010 M4FE*1U%K2D-2;4I#9VMA0G-O46<]/3\]"BTM+2T*4W5B:F5C=#H@86%A82!A
1011 M86%A(&%A86$@86%A82!A86%A(&%A86$@86%A80H@/3])4T\M,C`R,BU*4#]"
1012 M/T=Y4D-*0TEK2D-1;4I#9VM+:'-O46<]/3\](&%A86$@86%A82!A86%A(&%A
1013 )86$*+2TM+0H*
1014 eofeof
1015
1016 $example{'test_data/mime_out.ans.alt'} = unpack('u',<<'eofeof');
1017 M"BTM+2T*4W5B:F5C=#H@86%A82!A86%A(&%A86$@86%A82!A86%A(&%A86$@
1018 M86%A82!A86%A(&%A86$*(&%A86$@86%A82!A86%A(&%A86$@86%A80HM+2TM
1019 M"E-U8FIE8W0Z(#T_25-/+3(P,C(M2E`_0C]'>5)#2D-):TI#46U*0V=K2VE1
1020 M<DI#,&M,>5%X2D1-:TY343-'>6A#/ST*(#T_25-/+3(P,C(M2E`_0C]'>5)#
1021 M2D1K:T]Y43E*1#AK45-214I%66M30U)+2D5S:U1#4DY*131K5'E24TI&56M7
1022 M0U)B1WEH0S\]"B`]/TE33RTR,#(R+4I0/T(_1WE20TI&-&M8>5)G2D=%:UEI
1023 M4FM*0U%K6FE1;TI'9V)+14D]/ST*+2TM+0I3=6)J96-T.B!A86%A(&%A86$@
1024 M86%A82!A86%A(&%A86$@86%A82!A86%A"B`]/TE33RTR,#(R+4I0/T(_1WE2
1025 M0TI#26M*0U%M2D-G:TMH<V]19ST]/ST@86%A82!A86%A(&%A86$*(&%A86$*
1026 &+2TM+0H*
1027 eofeof
1028
1029 $example{'test_data/mime_out.ans.alt2'} = unpack('u',<<'eofeof');
1030 M"BTM+2T*4W5B:F5C=#H@86%A82!A86%A(&%A86$@86%A82!A86%A(&%A86$@
1031 M86%A82!A86%A(&%A86$@86%A82!A86%A(&%A86$@86%A80H@86%A80HM+2TM
1032 M"E-U8FIE8W0Z(#T_25-/+3(P,C(M2E`_0C]'>5)#2D-):TI#46U*0V=K2VE1
1033 M<DI#,&M,>5%X2D1-:TY343-*1&MK3WE1.4=Y:$,_/0H@/3])4T\M,C`R,BU*
1034 M4#]"/T=Y4D-*1#AK45-214I%66M30U)+2D5S:U1#4DY*131K5'E24TI&56M7
1035 M0U)B2D8T:UAY4F='>6A#/ST*(#T_25-/+3(P,C(M2E`_0C]'>5)#2D=%:UEI
1036 M4FM*0U%K6FE1;TI'9V)+14D]/ST*+2TM+0I3=6)J96-T.B!A86%A(&%A86$@
1037 M86%A82!A86%A(&%A86$@86%A82!A86%A(#T_25-/+3(P,C(M2E`_0C]'>5)#
1038 M2D-):TI"<V]19ST]/ST*(#T_25-/+3(P,C(M2E`_0C]'>5)#2D-9:TM#47%'
1039 @>6A#/ST@86%A82!A86%A(&%A86$@86%A80HM+2TM"@H`
1040 eofeof
1041
1042 $example{'test_data/mime_out.ans.alt3'} = unpack('u',<<'eofeof');
1043 M"BTM+2T*4W5B:F5C=#H@86%A82!A86%A(&%A86$@86%A82!A86%A(&%A86$@
1044 M86%A82!A86%A(&%A86$@86%A82!A86%A(&%A86$@86%A80H@86%A80HM+2TM
1045 M"E-U8FIE8W0Z(#T_25-/+3(P,C(M2E`_0C]'>5)#2D-):TI#46U*0V=K2VE1
1046 M<DI#,&M,>5%X2D1-:TY343-*1&MK3WE1.4=Y:$,_/0H@/3])4T\M,C`R,BU*
1047 M4#]"/T=Y4D-*1#AK45-214I%66M30U)+2D5S:U1#4DY*131K5'E24TI&56M7
1048 M0U)B2D8T:UAX<V]19ST]/ST*(#T_25-/+3(P,C(M2E`_0C]'>5)#2D=!:UE3
1049 M4FE*1U%K2D-2;4I#9VMA0G-O46<]/3\]"BTM+2T*4W5B:F5C=#H@86%A82!A
1050 M86%A(&%A86$@86%A82!A86%A(&%A86$@86%A82`]/TE33RTR,#(R+4I0/T(_
1051 M1WE20TI#26M*0G-O46<]/3\]"B`]/TE33RTR,#(R+4I0/T(_1WE20TI#66M+
1052 D0U%Q1WEH0S\](&%A86$@86%A82!A86%A(&%A86$*+2TM+0H*1
1053 eofeof
1054
1055 printf "%-40s", "test_data/mime_out";
1056     &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'});
1057 # test_data/mime_out3
1058
1059 $example{'test_data/mime_out3'} = "\x82\xD9\x82\xB0 A";
1060
1061 $example{'test_data/mime_out3.ans'} = "=?ISO-2022-JP?B?GyRCJFskMhsoQg==?= A";
1062
1063 printf "%-40s", "test_data/mime_out3";
1064     &test("$nkf -jSM",$example{'test_data/mime_out3'},$example{'test_data/mime_out3.ans'});
1065 # test_data/multi-line
1066
1067 $example{'test_data/multi-line'} = unpack('u',<<'eofeof');
1068 MI,JDK*2DI,JDK*2DI,JDK*'!I*2DKJ3GI*:DK*2BI.JDWJ2WI,:AH@"DLZ3L
1069 MI/*DO:3.I-ZDWJ2BI,2DJZ2FI,BAHJ3)I*:DXJ3?I-"DJ*2LI.^DZZ2DI+>A
1070 MHJ3(I,&DY:2FI,>DP:3GI/.DKJ3LI.NDJZ3BI+>D\Z3*I*2AHPJDLZ2SI,_#
1071 8NZ2DN=2AHP`*I+.DLZ3/P[NDI+G4H:,*
1072 eofeof
1073
1074 $example{'test_data/multi-line.ans'} = unpack('u',<<'eofeof');
1075 MI,JDK*2DI,JDK*2DI,JDK*'!I*2DKJ3GI*:DK*2BI.JDWJ2WI,:AH@"DLZ3L
1076 MI/*DO:3.I-ZDWJ2BI,2DJZ2FI,BAHJ3)I*:DXJ3?I-"DJ*2LI.^DZZ2DI+>A
1077 MHJ3(I,&DY:2FI,>DP:3GI/.DKJ3LI.NDJZ3BI+>D\Z3*I*2AHPJDLZ2SI,_#
1078 8NZ2DN=2AHP`*I+.DLZ3/P[NDI+G4H:,*
1079 eofeof
1080
1081 printf "%-40s", "test_data/multi-line";
1082     &test("$nkf -e",$example{'test_data/multi-line'},$example{'test_data/multi-line.ans'});
1083 # test_data/-Z4
1084
1085 $example{'test_data/-Z4'} = unpack('u',<<'eofeof');
1086 MH:.AUJ'7H:*AIJ&\H:NAK*6AI:*EHZ6DI:6EIJ6GI:BEJ:6JI:NEK*6MI:ZE
1087 MKZ6PI;&ELJ6SI;2EM:6VI;>EN*6YI;JENZ6\I;VEOJ6_I<"EP:7"I<.EQ*7%
1088 MI<:EQZ7(I<FERJ7+I<RES:7.I<^ET*71I=*ETZ74I=6EUJ77I=BEV:7:I=NE
1089 KW*7=I=ZEWZ7@I>&EXJ7CI>2EY:7FI>>EZ*7II>JEZZ7LI>VE[Z7RI?.E]```
1090 eofeof
1091
1092 $example{'test_data/-Z4.ans'} = unpack('u',<<'eofeof');
1093 MCJ&.HHZCCJ2.I8ZPCMZ.WXZGCK&.J(ZRCJF.LXZJCK2.JXZUCK:.MH[>CK>.
1094 MMX[>CKB.N([>CKF.N8[>CKJ.NH[>CKN.NX[>CKR.O([>CKV.O8[>CKZ.OH[>
1095 MCK^.OX[>CL".P([>CL&.P8[>CJ^.PH["CMZ.PX[#CMZ.Q([$CMZ.Q8[&CL>.
1096 MR([)CLJ.RH[>CLJ.WX[+CLN.WH[+CM^.S([,CMZ.S([?CLV.S8[>CLV.WX[.
1097 MCLZ.WH[.CM^.SX[0CM&.TH[3CJR.U(ZMCM6.KH[6CM>.V([9CMJ.VX[<CJ:.
1098 %W8ZSCMX`
1099 eofeof
1100
1101 printf "%-40s", "test_data/-Z4    ";
1102     &test("$nkf -eEZ4",$example{'test_data/-Z4'},$example{'test_data/-Z4.ans'});
1103 # test_data/nkf-19-bug-1
1104
1105 $example{'test_data/nkf-19-bug-1'} = unpack('u',<<'eofeof');
1106 ,I*:DJZ2D"KK8QJ,*
1107 eofeof
1108
1109 $example{'test_data/nkf-19-bug-1.ans'} = unpack('u',<<'eofeof');
1110 8&R1")"8D*R0D&RA""ALD0CI81B,;*$(*
1111 eofeof
1112
1113 printf "%-40s", "test_data/nkf-19-bug-1";
1114     &test("$nkf -Ej",$example{'test_data/nkf-19-bug-1'},$example{'test_data/nkf-19-bug-1.ans'});
1115 # test_data/nkf-19-bug-2
1116
1117 $example{'test_data/nkf-19-bug-2'} = unpack('u',<<'eofeof');
1118 %I-NDL@H`
1119 eofeof
1120
1121 $example{'test_data/nkf-19-bug-2.ans'} = unpack('u',<<'eofeof');
1122 %I-NDL@H`
1123 eofeof
1124
1125 printf "%-40s", "test_data/nkf-19-bug-2";
1126     &test("$nkf -Ee",$example{'test_data/nkf-19-bug-2'},$example{'test_data/nkf-19-bug-2.ans'});
1127 # test_data/nkf-19-bug-3
1128
1129 $example{'test_data/nkf-19-bug-3'} = unpack('u',<<'eofeof');
1130 8[;'Q\,&L"N6ZSN\*\NT)ON7.SL_+"0D*
1131 eofeof
1132
1133 $example{'test_data/nkf-19-bug-3.ans'} = unpack('u',<<'eofeof');
1134 8[;'Q\,&L"N6ZSN\*\NT)ON7.SL_+"0D*
1135 eofeof
1136
1137 printf "%-40s", "test_data/nkf-19-bug-3";
1138     &test("$nkf -e",$example{'test_data/nkf-19-bug-3'},$example{'test_data/nkf-19-bug-3.ans'});
1139 # test_data/non-strict-mime
1140
1141 $example{'test_data/non-strict-mime'} = unpack('u',<<'eofeof');
1142 M/3])4T\M,C`R,BU*4#]"/PIG<U-#;V]+.6=R-D-O;TQ%9W1Y0W0T1D-$46].
1143 M0V\V16=S,D]N;T999S1Y1%=)3$IG=4-0:UD*2W!G<FU#>$E+:6=R,D-V;TMI
1144 ,9W-30V]O3&,*/ST*
1145 eofeof
1146
1147 $example{'test_data/non-strict-mime.ans'} = unpack('u',<<'eofeof');
1148 M&R1")$8D)"0_)$`D)"1&)%XD.2$C&RA"#0H-"ALD0CMD)$\[?B$Y)6PE.21+
1149 <)&(]<20K)#LD1B0D)#\D0"0D)$8D)"1>&RA""@``
1150 eofeof
1151
1152 printf "%-40s", "test_data/non-strict-mime";
1153     &test("$nkf -jmN",$example{'test_data/non-strict-mime'},$example{'test_data/non-strict-mime.ans'});
1154 # test_data/q-encode-softrap
1155
1156 $example{'test_data/q-encode-softrap'} = unpack('u',<<'eofeof');
1157 H/3%")$(T03MZ)3T*,R$\)4DD3CTQ0BA""CTQ0B1"2E$T.3TQ0BA""@``
1158 eofeof
1159
1160 $example{'test_data/q-encode-softrap.ans'} = unpack('u',<<'eofeof');
1161 >&R1"-$$[>B4S(3PE221.&RA""ALD0DI1-#D;*$(*
1162 eofeof
1163
1164 printf "%-40s", "test_data/q-encode-softrap";
1165     &test("$nkf -jmQ",$example{'test_data/q-encode-softrap'},$example{'test_data/q-encode-softrap.ans'});
1166 # test_data/q-encode-utf-8
1167
1168 $example{'test_data/q-encode-utf-8'} = <<'eofeof';
1169 =?utf-8?Q?=E3=81=82=E3=81=84=E3=81=86=E3=81=88=E3=81=8A?=
1170 =?utf-8?Q?=E3=81=8B=E3=81=8D=E3=81=8F=E3=81=91=E3=81=93?=
1171 eofeof
1172
1173 $example{'test_data/q-encode-utf-8.ans'} = <<"eofeof";
1174 \xE3\x81\x82\xE3\x81\x84\xE3\x81\x86\xE3\x81\x88\xE3\x81\x8A
1175 \xE3\x81\x8B\xE3\x81\x8D\xE3\x81\x8F\xE3\x81\x91\xE3\x81\x93
1176 eofeof
1177
1178 printf "%-40s", "test_data/q-encode-utf-8";
1179     &test("$nkf -w",$example{'test_data/q-encode-utf-8'},$example{'test_data/q-encode-utf-8.ans'});
1180 # test_data/rot13
1181
1182 $example{'test_data/rot13'} = unpack('u',<<'eofeof');
1183 MI+.D\Z3+I,&DSZ&BS:W"]*3(I*2DI*3>I+FAHPH*;FMF('9E<BXQ+CDR(*3R
1184 MS?C-T:2UI+NDQJ2DI+^DP*2DI,:DI*3>I+FDK*&B05-#24D@I,O"T*2WI,8@
1185 M4D]4,3,@I*P*P+6DMZ2OQK"DI*3&I*2DRJ2DI.BDIJ3'H:*PRK*\I,ZDZ*2F
1186 MI,O*T;2YI+6D[*3>I+ND\Z&C"@HE(&5C:&\@)VAO9V4G('P@;FMF("UR"FAO
1187 #9V4*
1188 eofeof
1189
1190 $example{'test_data/rot13.ans'} = unpack('u',<<'eofeof');
1191 M&R1"4V)31%-Z4W!3?E!1?%QQ15-W4U-34U,O4VA04ALH0@H*87AS(&ER92XQ
1192 M+CDR(!LD0E-#?$E\(E-D4VI3=5-34VY3;U-34W534U,O4VA36U!1&RA"3D90
1193 M5E8@&R1"4WIQ(5-F4W4;*$(@14)',3,@&R1"4UL;*$(*&R1";V139E->=5]3
1194 M4U-U4U-3>5-34SE355-V4%%?>6%K4WU3.5-54WIY(F-H4V13/5,O4VI31%!2
1195 A&RA""@HE(')P=6(@)W5B='(G('P@87AS("UE"G5B='(*
1196 eofeof
1197
1198 printf "%-40s", "test_data/rot13";
1199     &test("$nkf -jr",$example{'test_data/rot13'},$example{'test_data/rot13.ans'});
1200 # test_data/slash
1201
1202 $example{'test_data/slash'} = unpack('u',<<'eofeof');
1203 7("`]/U8\5"U5.5=%2RTK.U<U32LE+PH`
1204 eofeof
1205
1206 $example{'test_data/slash.ans'} = unpack('u',<<'eofeof');
1207 7("`]/U8\5"U5.5=%2RTK.U<U32LE+PH`
1208 eofeof
1209
1210 printf "%-40s", "test_data/slash";
1211     &test("$nkf -j",$example{'test_data/slash'},$example{'test_data/slash.ans'});
1212 # test_data/z1space-0
1213
1214 $example{'test_data/z1space-0'} = unpack('u',<<'eofeof');
1215 "H:$`
1216 eofeof
1217
1218 $example{'test_data/z1space-0.ans'} = unpack('u',<<'eofeof');
1219 "H:$`
1220 eofeof
1221
1222 printf "%-40s", "test_data/z1space-0";
1223     &test("$nkf -e -Z",$example{'test_data/z1space-0'},$example{'test_data/z1space-0.ans'});
1224 # test_data/z1space-1
1225
1226 $example{'test_data/z1space-1'} = unpack('u',<<'eofeof');
1227 "H:$`
1228 eofeof
1229
1230 $example{'test_data/z1space-1.ans'} = unpack('u',<<'eofeof');
1231 !(```
1232 eofeof
1233
1234 printf "%-40s", "test_data/z1space-1";
1235     &test("$nkf -e -Z1",$example{'test_data/z1space-1'},$example{'test_data/z1space-1.ans'});
1236 # test_data/z1space-2
1237
1238 $example{'test_data/z1space-2'} = unpack('u',<<'eofeof');
1239 "H:$`
1240 eofeof
1241
1242 $example{'test_data/z1space-2.ans'} = unpack('u',<<'eofeof');
1243 "("``
1244 eofeof
1245
1246 printf "%-40s", "test_data/z1space-2";
1247     &test("$nkf -e -Z2",$example{'test_data/z1space-2'},$example{'test_data/z1space-2.ans'});
1248 # test_data/bug2273
1249
1250 $example{'test_data/bug2273'} = unpack('u',<<'eofeof');
1251 M/3]I<V\M,C`R,BUJ<#]Q/STY-CU!,CTX1CU",STY,3U&.#TX1$P].$0].3`]
1252 M.#$]038*:'1T<#HO+V5X86UP;&4N8V]M+S]O<&4]<V5L"FAT='`Z+R]E>&UA
1253 ,<&QE+FIP+PHN+BX*
1254 eofeof
1255
1256 $example{'test_data/bug2273.ans'} = unpack('u',<<'eofeof');
1257 MS*2^M<+ZN:VY\**H"FAT='`Z+R]E>&%M<&QE+F-O;2\_;W!E/7-E;`IH='1P
1258 3.B\O97AM87!L92YJ<"\*+BXN"@``
1259 eofeof
1260
1261 printf "%-40s", "test_data/bug2273";
1262     &test("$nkf -e",$example{'test_data/bug2273'},$example{'test_data/bug2273.ans'});
1263 # test_data/forum15899
1264
1265 $example{'test_data/forum15899'} = unpack('u',<<'eofeof');
1266 I6#H@XX&"XX&$XX&&XX&(XX&*XX&+XX&-XX&/XX&1XX&3XX&5(..!EPH`
1267 eofeof
1268
1269 $example{'test_data/forum15899.ans'} = unpack('u',<<'eofeof');
1270 M6#H@/3])4T\M,C`R,BU*4#]"/T=Y4D-*0TEK2D-1;4I#9VM+:5%R2D,P:TQY
1271 =47A*1$UK3E)S;U%I06)*14EK3GAS;U%G/3T_/0H`
1272 eofeof
1273
1274 printf "%-40s", "test_data/forum15899";
1275     &test("$nkf -Mj",$example{'test_data/forum15899'},$example{'test_data/forum15899.ans'});
1276 # test_data/bugs10904
1277
1278 $example{'test_data/bugs10904'} = unpack('u',<<'eofeof');
1279 M4W5B:F5C=#H@Z*FFZ:B3YY2HXX.AXX.\XX.KZ*&HZ:&,(.BIINFHD^>4J..#
1280 MH>.#O..#J^BAJ.FAC"#HJ:;IJ)/GE*CC@Z'C@[SC@ZOHH:CIH8P@Z*FFZ:B3
1281 3YY2HXX.AXX.\XX.KZ*&HZ:&,"@``
1282 eofeof
1283
1284 $example{'test_data/bugs10904.ans'} = unpack('u',<<'eofeof');
1285 M4W5B:F5C=#H@/3])4T\M,C`R,BU*4#]"/T=Y4D-/,C0T33`Q4DI716A00U9R
1286 ?4U0Q0V%H<V]1:4%B2D5)-V)J9WI45D5B2T5)/3\]"@``
1287 M(#T_25-/+3(P,C(M2E`_0C]'>5)#2E=%:%!#5G)35#%#86AS;U%I06)*14DW
1288 ?8FIG>E1616Q94T4X2E=T2E!52G%'>6A#24$]/3\]"@``
1289 M(#T_25-/+3(P,C(M2E`_0C]'>5)#3S(T-$TP,5)*5T5H4$-6<E-4,4-A:'-O
1290 '46<]/3\]"@``
1291 eofeof
1292
1293 printf "%-40s", "test_data/bugs10904";
1294     &test("$nkf -Mj",$example{'test_data/bugs10904'},$example{'test_data/bugs10904.ans'});
1295
1296 printf "%-40s", "test_data/ruby-dev:39722";
1297     &test("$nkf -MjW",<<eom,<<eom);
1298 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\xE3\x81\x82
1299 eom
1300 =?US-ASCII?Q?aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa?=
1301  =?US-ASCII?Q?aaaaaaaaaaaaaaaaa?= =?ISO-2022-JP?B?GyRCJCIbKEI=?=
1302 eom
1303 # test_data/bug19779
1304
1305 $example{'test_data/bug19779'} = unpack('u',<<'eofeof');
1306 2&R1","$;*$(*&R1"7V8;*$(*
1307 eofeof
1308
1309 $example{'test_data/bug19779.ans'} = unpack('u',<<'eofeof');
1310 M/3])4T\M,C`R,BU*4#]"/T=Y4D--0T5B2T5)/3\]"CT_25-/+3(P,C(M2E`_
1311 10C]'>5)#6#)98DM%23T_/0H`
1312 eofeof
1313
1314 printf "%-40s",  "test_data/bug19779    ";
1315     &test("$nkf -jM",$example{'test_data/bug19779'},$example{'test_data/bug19779.ans'});
1316
1317 printf "%-40s",  "[nkf-forum:47327]    ";
1318     &test("$nkf -wM",pack('H*','feffd852de76d814dc45000a'),"=?UTF-8?B?8KSptvCVgYU=?=\n");
1319
1320 printf "%-40s",  "[nkf-forum:47334]    ";
1321     &test("$nkf -w",pack('H*','feff006100620063000a'),"abc\n");
1322
1323 printf "%-40s",  "[nkf-bug:20079]    ";
1324     &test("$nkf -jSxM","\xBB \xBB","=?ISO-2022-JP?B?GyhJOxsoQiAbKEk7GyhC?=");
1325
1326 printf "%-40s",  "[nkf-bug:20079]    ";
1327     &test("$nkf -SxMw8","\xBB \xBB","=?UTF-8?B?77u/7727IO+9uw==?=");
1328
1329 printf "%-40s",  "[nkf-forum:48850]    ";
1330     &test("$nkf -jSM",
1331         "From: \x82\xA0\x82\xA0\x82\xA0\x82\xA0\x82\xA0\x82\xA0\x82\xA0\x82\xA0\x82\xA0" .
1332         " <x-xxxx@xxxxxxxxxxxx.co.jp>\n",
1333         "From: =?ISO-2022-JP?B?GyRCJCIkIiQiJCIkIiQiJCIkIiQiGyhC?=" .
1334         " <x-xxxx@xxxxxxxxxxxx.co.jp>\n");
1335
1336 printf "%-40s",  "[nkf-bug:21393]-x  ";
1337     &test("$nkf --ic=UTF-8 --oc=CP932",
1338     "\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",
1339     "\xBC\xDE\xAC\xB0\xCF\xDD\xA5\xCE\xDF\xC3\xC4\xA1");
1340
1341 printf "%-40s",  "[nkf-bug:21393]-X  ";
1342     &test("$nkf --ic=UTF-8 --oc=CP932 -X",
1343     "\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",
1344     "\x83W\x83\x83\x81[\x83}\x83\x93\x81E\x83|\x83e\x83g\x81B");
1345
1346 printf "%-40s",  "[nkf-forum:65316]  ";
1347     &test("$nkf -xwW -f10",
1348     "\xEF\xBD\xB1\xEF\xBD\xB2\xEF\xBD\xB3\xEF\xBD\xB4\xEF\xBD\xB5\xEF\xBD\xB6\xEF\xBD\xB7\xEF\xBD\xB8\xEF\xBD\xB9\xEF\xBD\xBA\xEF\xBD\xBB\xEF\xBD\xBC\xEF\xBD\xBD\xEF\xBD\xBE\xEF\xBD\xBF\xEF\xBE\x80\xEF\xBE\x81\xEF\xBE\x82\xEF\xBE\x83\xEF\xBE\x84",
1349     "\xEF\xBD\xB1\xEF\xBD\xB2\xEF\xBD\xB3\xEF\xBD\xB4\xEF\xBD\xB5\xEF\xBD\xB6\xEF\xBD\xB7\xEF\xBD\xB8\xEF\xBD\xB9\xEF\xBD\xBA\n\xEF\xBD\xBB\xEF\xBD\xBC\xEF\xBD\xBD\xEF\xBD\xBE\xEF\xBD\xBF\xEF\xBE\x80\xEF\xBE\x81\xEF\xBE\x82\xEF\xBE\x83\xEF\xBE\x84\n");
1350
1351 printf "%-40s",  "[nkf-forum:65482]  ";
1352     &test("$nkf --ic=CP50221 --oc=CP932",
1353     "\x1b\x24\x42\x7f\x21\x80\x21\x1b\x28\x42\n",
1354     "\xf0\x40\xf0\x9f\x0a");
1355
1356 printf "%-40s",  "[ruby-dev:47057]  ";
1357     &test("$nkf -jW -M --cp932",
1358     "\xe3\x80\x8c\xe3\x81\x82\xe3\x81\x82\xe3\x81\x82\xe3\x81\x82\xe3\x81\x82\xe3\x81\x82\xe3\x81\x82\xe3\x81\x82\xe3\x81\x82\xe3\x81\x82\xe3\x81\x82 by \xe3\x81\x82\xe3\x81\x82\xe3\x81\x82\xe3\x81\x82\xe3\x81\x82\xe3\x81\x82\xe3\x81\x82\xe3\x81\x82\xe3\x81\x82\xe3\x81\x82\xe3\x80\x8d\xe3\x81\xae\xe3\x83\xac\xe3\x82\xb7\xe3\x83\x94",
1359     "=?ISO-2022-JP?B?GyRCIVYkIiQiJCIkIiQiJCIkIiQiJCIkIiQiGyhC?= by\n =?ISO-2022-JP?B?GyRCJCIkIiQiJCIkIiQiJCIkIiQiJCIhVyROJWwlNyVUGyhC?=");
1360
1361     if (!NKF) {
1362 printf "%-40s", "Guess NL";
1363 &command_tests(
1364         "$nkf --guess","none",      "ASCII\n",
1365         "$nkf --guess","\n",        "ASCII (LF)\n",
1366         "$nkf --guess","\n\n",      "ASCII (LF)\n",
1367         "$nkf --guess","\n\r",      "ASCII (MIXED NL)\n",
1368         "$nkf --guess","\n\r\n",    "ASCII (MIXED NL)\n",
1369         "$nkf --guess","\n.\n",     "ASCII (LF)\n",
1370         "$nkf --guess","\n.\r",     "ASCII (MIXED NL)\n",
1371         "$nkf --guess","\n.\r\n",   "ASCII (MIXED NL)\n",
1372         "$nkf --guess","\r",        "ASCII (CR)\n",
1373         "$nkf --guess","\r\r",      "ASCII (CR)\n",
1374         "$nkf --guess","\r\r\n",    "ASCII (MIXED NL)\n",
1375         "$nkf --guess","\r.\n",     "ASCII (MIXED NL)\n",
1376         "$nkf --guess","\r.\r",     "ASCII (CR)\n",
1377         "$nkf --guess","\r.\r\n",   "ASCII (MIXED NL)\n",
1378         "$nkf --guess","\r\n",      "ASCII (CRLF)\n",
1379         "$nkf --guess","\r\n\n",    "ASCII (MIXED NL)\n",
1380         "$nkf --guess","\r\n\r",    "ASCII (MIXED NL)\n",
1381         "$nkf --guess","\r\n\r\n",  "ASCII (CRLF)\n",
1382         "$nkf --guess","\r\n.\n",   "ASCII (MIXED NL)\n",
1383         "$nkf --guess","\r\n.\r",   "ASCII (MIXED NL)\n",
1384         "$nkf --guess","\r\n.\r\n", "ASCII (CRLF)\n");
1385     }
1386
1387 printf "%-40s", "Convert NL to LF";
1388 &command_tests(
1389         "$nkf -jLu","none",      "none",
1390         "$nkf -jLu","\n",        "\n",
1391         "$nkf -jLu","\n\n",      "\n\n",
1392         "$nkf -jLu","\n\r",      "\n\n",
1393         "$nkf -jLu","\n\r\n",    "\n\n",
1394         "$nkf -jLu","\n.\n",     "\n.\n",
1395         "$nkf -jLu","\n.\r",     "\n.\n",
1396         "$nkf -jLu","\n.\r\n",   "\n.\n",
1397         "$nkf -jLu","\r",        "\n",
1398         "$nkf -jLu","\r\r",      "\n\n",
1399         "$nkf -jLu","\r\r\n",    "\n\n",
1400         "$nkf -jLu","\r.\n",     "\n.\n",
1401         "$nkf -jLu","\r.\r",     "\n.\n",
1402         "$nkf -jLu","\r.\r\n",   "\n.\n",
1403         "$nkf -jLu","\r\n",      "\n",
1404         "$nkf -jLu","\r\n\n",    "\n\n",
1405         "$nkf -jLu","\r\n\r",    "\n\n",
1406         "$nkf -jLu","\r\n\r\n",  "\n\n",
1407         "$nkf -jLu","\r\n.\n",   "\n.\n",
1408         "$nkf -jLu","\r\n.\r",   "\n.\n",
1409         "$nkf -jLu","\r\n.\r\n", "\n.\n");
1410
1411 printf "%-40s", "Convert NL to LF";
1412 &command_tests(
1413         "$nkf -jLm","none",      "none",
1414         "$nkf -jLm","\n",        "\r",
1415         "$nkf -jLm","\n\n",      "\r\r",
1416         "$nkf -jLm","\n\r",      "\r\r",
1417         "$nkf -jLm","\n\r\n",    "\r\r",
1418         "$nkf -jLm","\n.\n",     "\r.\r",
1419         "$nkf -jLm","\n.\r",     "\r.\r",
1420         "$nkf -jLm","\n.\r\n",   "\r.\r",
1421         "$nkf -jLm","\r",        "\r",
1422         "$nkf -jLm","\r\r",      "\r\r",
1423         "$nkf -jLm","\r\r\n",    "\r\r",
1424         "$nkf -jLm","\r.\n",     "\r.\r",
1425         "$nkf -jLm","\r.\r",     "\r.\r",
1426         "$nkf -jLm","\r.\r\n",   "\r.\r",
1427         "$nkf -jLm","\r\n",      "\r",
1428         "$nkf -jLm","\r\n\n",    "\r\r",
1429         "$nkf -jLm","\r\n\r",    "\r\r",
1430         "$nkf -jLm","\r\n\r\n",  "\r\r",
1431         "$nkf -jLm","\r\n.\n",   "\r.\r",
1432         "$nkf -jLm","\r\n.\r",   "\r.\r",
1433         "$nkf -jLm","\r\n.\r\n", "\r.\r");
1434
1435 printf "%-40s", "Convert NL to CRLF";
1436 &command_tests(
1437         "$nkf -jLw","none",      "none",
1438         "$nkf -jLw","\n",        "\r\n",
1439         "$nkf -jLw","\n\n",      "\r\n\r\n",
1440         "$nkf -jLw","\n\r",      "\r\n\r\n",
1441         "$nkf -jLw","\n\r\n",    "\r\n\r\n",
1442         "$nkf -jLw","\n.\n",     "\r\n.\r\n",
1443         "$nkf -jLw","\n.\r",     "\r\n.\r\n",
1444         "$nkf -jLw","\n.\r\n",   "\r\n.\r\n",
1445         "$nkf -jLw","\r",        "\r\n",
1446         "$nkf -jLw","\r\r",      "\r\n\r\n",
1447         "$nkf -jLw","\r\r\n",    "\r\n\r\n",
1448         "$nkf -jLw","\r.\n",     "\r\n.\r\n",
1449         "$nkf -jLw","\r.\r",     "\r\n.\r\n",
1450         "$nkf -jLw","\r.\r\n",   "\r\n.\r\n",
1451         "$nkf -jLw","\r\n",      "\r\n",
1452         "$nkf -jLw","\r\n\n",    "\r\n\r\n",
1453         "$nkf -jLw","\r\n\r",    "\r\n\r\n",
1454         "$nkf -jLw","\r\n\r\r\n",  "\r\n\r\n\r\n",
1455         "$nkf -jLw","\r\n.\n",   "\r\n.\r\n",
1456         "$nkf -jLw","\r\n.\r",   "\r\n.\r\n",
1457         "$nkf -jLw","\r\n.\r\n", "\r\n.\r\n");
1458 # end