OSDN Git Service

46a2973dd63af9de940e2e6e07e99645dac2c129
[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. It also accepts EUC-JP.
127 This is the default. This flag does not exclude Shift_JIS.
128
129 =item B<-S>
130
131 Assume Shift_JIS and X0201 kana input. It also accepts JIS.
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. It also accepts JIS.
138 Same as -J.
139
140 =back
141
142 =item B<-t>
143
144 No conversion.
145
146 =item B<-i[@B]>
147
148 Specify the Esc Seq for JIS X 0208-1978/83. (DEFAULT B)
149
150 =item B<-o[BJH]>
151
152 Specify the Esc Seq for ASCII/Roman. (DEFAULT B)
153
154 =item B<-r>
155
156 {de/en}crypt ROT13/47
157
158 =item B<-h[123] --hiragana --katakana --katakana-hiragana>
159
160 =over
161
162 =item B<-h1 --hiragana>
163
164 Katakana to Hiragana conversion.
165
166 =item B<-h2 --katakana>
167
168 Hiragana to Katakana conversion.
169
170 =item B<-h3 --katakana-hiragana>
171
172 Katakana to Hiragana and Hiragana to Katakana conversion.
173
174 =back
175
176 =item B<-T>
177
178 Text mode output (MS-DOS)
179
180 =item B<-l>
181
182 ISO8859-1 (Latin-1) support
183
184 =item B<-f[I<m> [- I<n>]]>
185
186 Folding on I<m> length with I<n> margin in a line.
187 Without this option, fold length is 60 and fold margin is 10.
188
189 =item B<-F>
190
191 New line preserving line folding.
192
193 =item B<-Z[0-3]>
194
195 Convert X0208 alphabet (Fullwidth Alphabets) to ASCII.
196
197 =over
198
199 =item B<-Z -Z0>
200
201 Convert X0208 alphabet to ASCII.
202
203 =item B<-Z1>
204
205 Converts X0208 kankaku to single ASCII space.
206
207 =item B<-Z2>
208
209 Converts X0208 kankaku to double ASCII spaces.
210
211 =item B<-Z3>
212
213 Replacing Fullwidth >, <, ", & into '&gt;', '&lt;', '&quot;', '&amp;' as in HTML.
214
215 =back
216
217 =item B<-X -x>
218
219 Assume X0201 kana in MS-Kanji.
220 With B<-X> or without this option, X0201 is converted into X0208 Kana.
221 With B<-x>, try to preserve X0208 kana and do not convert X0201 kana to X0208.
222 In JIS output, ESC-(-I is used. In EUC output, SSO is used.
223
224 =item B<-B[0-2]>
225
226 Assume broken JIS-Kanji input, which lost ESC.
227 Useful when your site is using old B-News Nihongo patch.
228
229 =over
230
231 =item B<-B1>
232
233 allows any char after ESC-( or ESC-$.
234
235 =item B<-B2>
236
237 forces ASCII after NL.
238
239 =back
240
241 =item B<-I>
242
243 Replacing non iso-2022-jp char into a geta character
244 (substitute character in Japanese).
245
246 =item B<-m[BQN0]>
247
248 MIME ISO-2022-JP/ISO8859-1 decode. (DEFAULT)
249 To see ISO8859-1 (Latin-1) -l is necessary.
250
251 =over
252
253 =item B<-mB>
254
255 Decode MIME base64 encoded stream. Remove header or other part before
256 conversion. 
257
258 =item B<-mQ>
259
260 Decode MIME quoted stream. '_' in quoted stream is converted to space.
261
262 =item B<-mN>
263
264 Non-strict decoding.
265 It allows line break in the middle of the base64 encoding.
266
267 =item B<-m0>
268
269 No MIME decode.
270
271 =back
272
273 =item B<-M>
274
275 MIME encode. Header style. All ASCII code and control characters are intact.
276
277 =over
278
279 =item B<-MB>
280
281 MIME encode Base64 stream.
282 Kanji conversion is performed before encoding, so this cannot be used as a picture encoder.
283
284 =item B<-MQ>
285
286 Perfome quoted encoding.
287
288 =back
289
290 =item B<-l>
291
292 Input and output code is ISO8859-1 (Latin-1) and ISO-2022-JP.
293 B<-s>, B<-e> and B<-x> are not compatible with this option.
294
295 =item B<-L[uwm] -d -c>
296
297 Convert line breaks.
298
299 =over
300
301 =item B<-Lu -d>
302
303 unix (LF)
304
305 =item B<-Lw -c>
306
307 windows (CRLF)
308
309 =item B<-Lm>
310
311 mac (CR)
312
313 Without this option, nkf doesn't convert line breaks.
314
315 =back
316
317 =item B<--fj --unix --mac --msdos --windows>
318
319 convert for these system
320
321 =item B<--jis --euc --sjis --mime --base64>
322
323 convert for named code
324
325 =item B<--jis-input --euc-input --sjis-input --mime-input --base64-input>
326
327 assume input system
328
329 =item B<--ic=I<input codeset> --oc=I<output codeset>>
330
331 Set the input or output codeset.
332 NKF supports following codesets and those codeset name are case insensitive.
333
334 =over
335
336 =item ISO-2022-JP
337
338 a.k.a. RFC1468, 7bit JIS, JUNET
339
340 =item EUC-JP (eucJP-nkf)
341
342 a.k.a. AT&T JIS, Japanese EUC, UJIS
343
344 =item eucJP-ascii
345
346 =item eucJP-ms
347
348 =item CP51932
349
350 Microsoft Version of EUC-JP.
351
352 =item Shift_JIS
353
354 a.k.a. SJIS, MS-Kanji
355
356 =item CP932
357
358 a.k.a. Windows-31J
359
360 =item UTF-8
361
362 same as UTF-8N
363
364 =item UTF-8N
365
366 UTF-8 without BOM
367
368 =item UTF-8-BOM
369
370 UTF-8 with BOM
371
372 =item UTF8-MAC (input only)
373
374 decomposed UTF-8
375
376 =item UTF-16
377
378 same as UTF-16BE
379
380 =item UTF-16BE
381
382 UTF-16 Big Endian without BOM
383
384 =item UTF-16BE-BOM
385
386 UTF-16 Big Endian with BOM
387
388 =item UTF-16LE
389
390 UTF-16 Little Endian without BOM
391
392 =item UTF-16LE-BOM
393
394 UTF-16 Little Endian with BOM
395
396 =back
397
398 =item B<--fb-{skip, html, xml, perl, java, subchar}>
399
400 Specify the way that nkf handles unassigned characters.
401 Without this option, --fb-skip is assumed.
402
403 =item B<--prefix=I<escape character>I<target character>..>
404
405 When nkf converts to Shift_JIS,
406 nkf adds a specified escape character to specified 2nd byte of Shift_JIS characters.
407 1st byte of argument is the escape character and following bytes are target characters.
408
409 =item B<--no-cp932ext>
410
411 Handle the characters extended in CP932 as unassigned characters.
412
413 =item B<--no-best-fit-chars>
414
415 When Unicode to Encoded byte conversion,
416 don't convert characters which is not round trip safe.
417 When Unicode to Unicode conversion,
418 with this and -x option, nkf can be used as UTF converter.
419 (In other words, without this and -x option, nkf doesn't save some characters)
420
421 When nkf convert string which related to path, you should use this opion.
422
423 =item B<--cap-input>
424
425 Decode hex encoded characters.
426
427 =item B<--url-input>
428
429 Unescape percent escaped characters.
430
431 =item B<--numchar-input>
432
433 Decode character reference, such as "&#....;".
434
435 =begin COMMAND
436
437 =item B<--in-place[=>I<SUFFIX>B<]>  B<--overwrite[=>I<SUFFIX>B<]>
438
439 Overwrite B<original> listed files by filtered result.
440
441 B<Note> --overwrite preserves timestamp of original files.
442
443 =item B<--guess>
444
445 Print guessed encoding.
446
447 =item B<--help>
448
449 Print nkf's help.
450
451 =item B<--version>
452
453 Print nkf's version.
454
455 =end
456
457 =item B<-->
458
459 Ignore rest of -option.
460
461 =back
462
463 =head1 AUTHOR
464
465 Copyright (C) 1987, FUJITSU LTD. (I.Ichikawa),2000 S. Kono, COW
466 Copyright (C) 2002-2006 Kono, Furukawa, Naruse, mastodon
467
468 =begin
469
470 =head1 SEE ALSO
471
472 perl(1).   nkf(1)
473
474 =end
475
476 =cut