OSDN Git Service

4bb0d1c78abd54dbb7666802703ef816e349e625
[nkf/nkf.git] / NKF.mod / NKF.pm
1 ## Copyright (C) 1996,1998
2 ## Copyright (C) 2002
3 ## Ï¢ÍíÀ衧 Î°µåÂç³Ø¾ðÊ󹩳زʠ²ÏÌî ¿¿¼£  mime/X0208 support
4 ## ¡ÊE-Mail Address: kono@ie.u-ryukyu.ac.jp¡Ë
5 ## Ï¢ÍíÀ衧 COW for DOS & Win16 & Win32 & OS/2
6 ## ¡ÊE-Mail Address: GHG00637@niftyserve.or.p¡Ë
7 ##    
8 ##    ¤³¤Î¥½¡¼¥¹¤Î¤¤¤«¤Ê¤ëÊ£¼Ì¡¤²þÊÑ¡¤½¤Àµ¤âµöÂú¤·¤Þ¤¹¡£¤¿¤À¤·¡¢
9 ##    ¤½¤ÎºÝ¤Ë¤Ï¡¢Ã¯¤¬¹×¸¥¤·¤¿¤ò¼¨¤¹¤³¤ÎÉôʬ¤ò»Ä¤¹¤³¤È¡£
10 ##    ºÆÇÛÉۤ仨»ï¤ÎÉÕÏ¿¤Ê¤É¤ÎÌ䤤¹ç¤ï¤»¤âɬÍפ¢¤ê¤Þ¤»¤ó¡£
11 ##    ±ÄÍøÍøÍѤâ¾åµ­¤ËÈ¿¤·¤Ê¤¤ÈϰϤǵö²Ä¤·¤Þ¤¹¡£
12 ##    ¥Ð¥¤¥Ê¥ê¤ÎÇÛÉۤκݤˤÏversion message¤òÊݸ¤¹¤ë¤³¤È¤ò¾ò·ï¤È¤·¤Þ¤¹¡£
13 ##    ¤³¤Î¥×¥í¥°¥é¥à¤Ë¤Ä¤¤¤Æ¤ÏÆä˲¿¤ÎÊݾڤ⤷¤Ê¤¤¡¢°­¤·¤«¤é¤º¡£
14 ##    
15 ##    Everyone is permitted to do anything on this program
16 ##    including copying, modifying, improving, 
17 ##    as long as you don't try to pretend that you wrote it.
18 ##    i.e., the above copyright notice has to appear in all copies.  
19 ##    Binar y distribution requires original version messages.
20 ##    You don't have to ask before copying, redistribution or publishing.
21 ##    THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE.
22
23
24 package NKF;
25
26 use strict;
27 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
28
29 require Exporter;
30 require DynaLoader;
31
32 @ISA = qw(Exporter DynaLoader);
33 # Items to export into callers namespace by default. Note: do not export
34 # names by default without a very good reason. Use EXPORT_OK instead.
35 # Do not simply export all your public functions/methods/constants.
36 @EXPORT = qw(
37         nkf     nkf_continue    inputcode
38 );
39 $VERSION = '2.08';
40
41 bootstrap NKF $VERSION;
42
43 # Preloaded methods go here.
44
45 # Autoload methods go after =cut, and are processed by the autosplit program.
46
47 1;
48 __END__
49
50 #
51 # =begin ¤«¤é =begin COMMAND ¤Þ¤Ç¤Ï Perl/NKF ¤Î¥É¥­¥å¥á¥ó¥È
52 # =begin COMMAND ¤«¤é =end ¤Þ¤Ç¤Ï nkf ¥³¥Þ¥ó¥É¤Î¥É¥­¥å¥á¥ó¥È
53
54
55 =head1 NAME
56
57 =begin
58
59 NKF - Perl extension for Network Kanji Filter
60
61 =begin COMMAND
62
63 nkf - Network Kanji Filter
64
65 =end
66
67 =head1 SYNOPSIS
68
69 =begin
70
71   use NKF;
72   $output = nkf("-s",$input);
73
74 =begin COMMAND
75
76 nkf B<[-butjnesliohrTVvwWJESZxXFfmMBOcdILg]> B<[>I<file ...>B<]>
77
78 =end
79
80 =head1 DESCRIPTION
81
82 =begin
83
84 This is a Perl Extension version of nkf (Netowrk Kanji Filter).
85 It converts the last argument and return converted result. Conversion
86 details are specified by flags before the last argument.
87
88 =end
89
90 B<Nkf> is a yet another kanji code converter among networks, hosts and terminals.
91 It converts input kanji code to designated kanji code
92 such as ISO-2022-JP, Shift_JIS, EUC-JP, UTF-8 or UTF-16.
93
94 One of the most unique faculty of B<nkf> is the guess of the input kanji encodings.
95 It currently recognizes ISO-2022-JP, Shift_JIS, EUC-JP, UTF-8 and UTF-16.
96 So users needn't set the input kanji code explicitly.
97
98 By default, X0201 kana is converted into X0208 kana.
99 For X0201 kana, SO/SI, SSO and ESC-(-I methods are supported.
100 For automatic code detection, nkf assumes no X0201 kana in Shift_JIS.
101 To accept X0201 in Shift_JIS, use B<-X>, B<-x> or B<-S>.
102
103 =head1 OPTIONS
104
105 =over
106
107 =item B<-b -u>
108
109 Output is buffered (DEFAULT), Output is unbuffered.
110
111 =item B<-j -s -e -w -w16>
112
113 Output code is ISO-2022-JP (7bit JIS), Shift_JIS, EUC-JP,
114 UTF-8N, UTF-16BE.
115 Without this option and compile option, ISO-2022-JP is assumed.
116
117 =item B<-J -S -E -W -W16>
118
119 Input assumption is JIS 7 bit, Shift_JIS, EUC-JP,
120 UTF-8, UTF-16LE.
121
122 =over
123
124 =item B<-J>
125
126 Assume  JIS input.
127 This is the default.
128
129 =item B<-S>
130
131 Assume Shift_JIS and X0201 kana input.
132 EUC-JP is recognized as X0201 kana. Without B<-x> flag,
133 X0201 kana (halfwidth kana) is converted into X0208.
134
135 =item B<-E>
136
137 Assume EUC-JP input.
138
139 =back
140
141 =item B<-t>
142
143 No conversion.
144
145 =item B<-i[@B]>
146
147 Specify the Esc Seq for JIS X 0208-1978/83. (DEFAULT B)
148
149 =item B<-o[BJH]>
150
151 Specify the Esc Seq for ASCII/Roman. (DEFAULT B)
152
153 =item B<-r>
154
155 {de/en}crypt ROT13/47
156
157 =item B<-h[123] --hiragana --katakana --katakana-hiragana>
158
159 =over
160
161 =item B<-h1 --hiragana>
162
163 Katakana to Hiragana conversion.
164
165 =item B<-h2 --katakana>
166
167 Hiragana to Katakana conversion.
168
169 =item B<-h3 --katakana-hiragana>
170
171 Katakana to Hiragana and Hiragana to Katakana conversion.
172
173 =back
174
175 =item B<-T>
176
177 Text mode output (MS-DOS)
178
179 =item B<-l>
180
181 ISO8859-1 (Latin-1) support
182
183 =item B<-f[I<m> [- I<n>]]>
184
185 Folding on I<m> length with I<n> margin in a line.
186 Without this option, fold length is 60 and fold margin is 10.
187
188 =item B<-F>
189
190 New line preserving line folding.
191
192 =item B<-Z[0-3]>
193
194 Convert X0208 alphabet (Fullwidth Alphabets) to ASCII.
195
196 =over
197
198 =item B<-Z -Z0>
199
200 Convert X0208 alphabet to ASCII.
201
202 =item B<-Z1>
203
204 Convert X0208 kankaku to single ASCII space.
205
206 =item B<-Z2>
207
208 Convert X0208 kankaku to double ASCII spaces.
209
210 =item B<-Z3>
211
212 Replacing fullwidth >, <, ", & into '&gt;', '&lt;', '&quot;', '&amp;' as in HTML.
213
214 =back
215
216 =item B<-X -x>
217
218 Assume X0201 kana in MS-Kanji.
219 With B<-X> or without this option, X0201 is converted into X0208 Kana.
220 With B<-x>, try to preserve X0208 kana and do not convert X0201 kana to X0208.
221 In JIS output, ESC-(-I is used. In EUC output, SSO is used.
222
223 =item B<-B[0-2]>
224
225 Assume broken JIS-Kanji input, which lost ESC.
226 Useful when your site is using old B-News Nihongo patch.
227
228 =over
229
230 =item B<-B1>
231
232 allows any chars after ESC-( or ESC-$.
233
234 =item B<-B2>
235
236 force ASCII after NL.
237
238 =back
239
240 =item B<-I>
241
242 Replacing non iso-2022-jp char into a geta character
243 (substitute character in Japanese).
244
245 =item B<-m[BQN0]>
246
247 MIME ISO-2022-JP/ISO8859-1 decode. (DEFAULT)
248 To see ISO8859-1 (Latin-1) -l is necessary.
249
250 =over
251
252 =item B<-mB>
253
254 Decode MIME base64 encoded stream. Remove header or other part before
255 conversion. 
256
257 =item B<-mQ>
258
259 Decode MIME quoted stream. '_' in quoted stream is converted to space.
260
261 =item B<-mN>
262
263 Non-strict decoding.
264 It allows line break in the middle of the base64 encoding.
265
266 =item B<-m0>
267
268 No MIME decode.
269
270 =back
271
272 =item B<-M>
273
274 MIME encode. Header style. All ASCII code and control characters are intact.
275
276 =over
277
278 =item B<-MB>
279
280 MIME encode Base64 stream.
281 Kanji conversion is performed before encoding, so this cannot be used as a picture encoder.
282
283 =item B<-MQ>
284
285 Perform quoted encoding.
286
287 =back
288
289 =item B<-l>
290
291 Input and output code is ISO8859-1 (Latin-1) and ISO-2022-JP.
292 B<-s>, B<-e> and B<-x> are not compatible with this option.
293
294 =item B<-L[uwm] -d -c>
295
296 Convert line breaks.
297
298 =over
299
300 =item B<-Lu -d>
301
302 unix (LF)
303
304 =item B<-Lw -c>
305
306 windows (CRLF)
307
308 =item B<-Lm>
309
310 mac (CR)
311
312 Without this option, nkf doesn't convert line breaks.
313
314 =back
315
316 =item B<--fj --unix --mac --msdos --windows>
317
318 Convert for these systems.
319
320 =item B<--jis --euc --sjis --mime --base64>
321
322 Convert to named code.
323
324 =item B<--jis-input --euc-input --sjis-input --mime-input --base64-input>
325
326 Assume input system
327
328 =item B<--ic=I<input codeset> --oc=I<output codeset>>
329
330 Set the input or output codeset.
331 NKF supports following codesets and those codeset names are case insensitive.
332
333 =over
334
335 =item ISO-2022-JP
336
337 a.k.a. RFC1468, 7bit JIS, JUNET
338
339 =item EUC-JP (eucJP-nkf)
340
341 a.k.a. AT&T JIS, Japanese EUC, UJIS
342
343 =item eucJP-ascii
344
345 =item eucJP-ms
346
347 =item CP51932
348
349 Microsoft Version of EUC-JP.
350
351 =item Shift_JIS
352
353 a.k.a. SJIS, MS-Kanji
354
355 =item CP932
356
357 a.k.a. Windows-31J
358
359 =item UTF-8
360
361 same as UTF-8N
362
363 =item UTF-8N
364
365 UTF-8 without BOM
366
367 =item UTF-8-BOM
368
369 UTF-8 with BOM
370
371 =item UTF8-MAC (input only)
372
373 decomposed UTF-8
374
375 =item UTF-16
376
377 same as UTF-16BE
378
379 =item UTF-16BE
380
381 UTF-16 Big Endian without BOM
382
383 =item UTF-16BE-BOM
384
385 UTF-16 Big Endian with BOM
386
387 =item UTF-16LE
388
389 UTF-16 Little Endian without BOM
390
391 =item UTF-16LE-BOM
392
393 UTF-16 Little Endian with BOM
394
395 =back
396
397 =item B<--fb-{skip, html, xml, perl, java, subchar}>
398
399 Specify the way that nkf handles unassigned characters.
400 Without this option, --fb-skip is assumed.
401
402 =item B<--prefix=I<escape character>I<target character>..>
403
404 When nkf converts to Shift_JIS,
405 nkf adds a specified escape character to specified 2nd byte of Shift_JIS characters.
406 1st byte of argument is the escape character and following bytes are target characters.
407
408 =item B<--no-cp932ext>
409
410 Handle the characters extended in CP932 as unassigned characters.
411
412 =item B<--no-best-fit-chars>
413
414 When Unicode to Encoded byte conversion,
415 don't convert characters which is not round trip safe.
416 When Unicode to Unicode conversion,
417 with this and -x option, nkf can be used as UTF converter.
418 (In other words, without this and -x option, nkf doesn't save some characters)
419
420 When nkf converts strings that related to path, you should use this opion.
421
422 =item B<--cap-input>
423
424 Decode hex encoded characters.
425
426 =item B<--url-input>
427
428 Unescape percent escaped characters.
429
430 =item B<--numchar-input>
431
432 Decode character reference, such as "&#....;".
433
434 =begin COMMAND
435
436 =item B<--in-place[=>I<SUFFIX>B<]>  B<--overwrite[=>I<SUFFIX>B<]>
437
438 Overwrite B<original> listed files by filtered result.
439
440 B<Note> --overwrite preserves timestamps of original files.
441
442 =item B<--guess>
443
444 Print guessed encoding.
445
446 =item B<--help>
447
448 Print nkf's help.
449
450 =item B<--version>
451
452 Print nkf's version.
453
454 =end
455
456 =item B<-->
457
458 Ignore rest of -option.
459
460 =back
461
462 =head1 AUTHOR
463
464 Copyright (C) 1987, FUJITSU LTD. (I.Ichikawa),2000 S. Kono, COW
465 Copyright (C) 2002-2007 Kono, Furukawa, Naruse, mastodon
466
467 =begin
468
469 =head1 SEE ALSO
470
471 perl(1).   nkf(1)
472
473 =end
474
475 =cut