OSDN Git Service

Update documents.
[nkf/nkf.git] / NKF.mod / NKF.pm
1 # Copyright (c) 1987, Fujitsu LTD. (Itaru ICHIKAWA).
2 # Copyright (c) 1996-2009, The nkf Project.
3 # All rights reserved.
4 #
5 # This software is provided 'as-is', without any express or implied
6 # warranty. In no event will the authors be held liable for any damages
7 # arising from the use of this software.
8 #
9 # Permission is granted to anyone to use this software for any purpose,
10 # including commercial applications, and to alter it and redistribute it
11 # freely, subject to the following restrictions:
12 #
13 # 1. The origin of this software must not be misrepresented; you must not
14 # claim that you wrote the original software. If you use this software
15 # in a product, an acknowledgment in the product documentation would be
16 # appreciated but is not required.
17 #
18 # 2. Altered source versions must be plainly marked as such, and must not be
19 # misrepresented as being the original software.
20 #
21 # 3. This notice may not be removed or altered from any source distribution.
22
23 package NKF;
24
25 use strict;
26 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
27
28 require Exporter;
29 require DynaLoader;
30
31 @ISA = qw(Exporter DynaLoader);
32 # Items to export into callers namespace by default. Note: do not export
33 # names by default without a very good reason. Use EXPORT_OK instead.
34 # Do not simply export all your public functions/methods/constants.
35 @EXPORT = qw(
36         nkf     nkf_continue    inputcode
37 );
38 $VERSION = '2.09';
39
40 bootstrap NKF $VERSION;
41
42 # Preloaded methods go here.
43
44 # Autoload methods go after =cut, and are processed by the autosplit program.
45
46 1;
47 __END__
48
49 #
50 # =begin ¤«¤é =begin COMMAND ¤Þ¤Ç¤Ï Perl/NKF ¤Î¥É¥­¥å¥á¥ó¥È
51 # =begin COMMAND ¤«¤é =end ¤Þ¤Ç¤Ï nkf ¥³¥Þ¥ó¥É¤Î¥É¥­¥å¥á¥ó¥È
52
53
54 =head1 NAME
55
56 =begin
57
58 NKF - Perl extension for Network Kanji Filter
59
60 =begin COMMAND
61
62 nkf - Network Kanji Filter
63
64 =end
65
66 =head1 SYNOPSIS
67
68 =begin
69
70   use NKF;
71   $output = nkf("-s",$input);
72
73 =begin COMMAND
74
75 nkf B<[-butjnesliohrTVvwWJESZxXFfmMBOcdILg]> B<[>I<file ...>B<]>
76
77 =end
78
79 =head1 DESCRIPTION
80
81 =begin
82
83 This is a Perl Extension version of nkf (Netowrk Kanji Filter).
84 It converts the last argument and return converted result. Conversion
85 details are specified by flags before the last argument.
86
87 =end
88
89 B<Nkf> is a yet another kanji code converter among networks, hosts and terminals.
90 It converts input kanji code to designated kanji code
91 such as ISO-2022-JP, Shift_JIS, EUC-JP, UTF-8, UTF-16 or UTF-32.
92
93 One of the most unique faculty of B<nkf> is the guess of the input kanji encodings.
94 It currently recognizes ISO-2022-JP, Shift_JIS, EUC-JP, UTF-8, UTF-16 and UTF-32.
95 So users needn't set the input kanji code explicitly.
96
97 By default, X0201 kana is converted into X0208 kana.
98 For X0201 kana, SO/SI, SSO and ESC-(-I methods are supported.
99 For automatic code detection, nkf assumes no X0201 kana in Shift_JIS.
100 To accept X0201 in Shift_JIS, use B<-X>, B<-x> or B<-S>.
101
102 =head1 OPTIONS
103
104 =over
105
106 =item B<-J -S -E -W -W16 -W32 -j -s -e -w -w16 -w32>
107
108 Specify input and output encodings. Upper case is input.
109 cf. --ic and --oc.
110
111 =over
112
113 =item B<-J>
114
115 ISO-2022-JP (JIS code).
116
117 =item B<-S>
118
119 Shift_JIS and JIS X 0201 kana.
120 EUC-JP is recognized as X0201 kana. Without B<-x> flag,
121 JIS X 0201 Katakana (a.k.a.halfwidth kana) is converted into JIS X 0208.
122 If you use Windows, see Windows-31J (CP932).
123
124 =item B<-E>
125
126 EUC-JP.
127
128 =item B<-W>
129
130 UTF-8N.
131
132 =item B<-W16[BL][0]>
133
134 UTF-16.
135 B or L gives whether Big Endian or Little Endian.
136 0 gives whther put BOM or not.
137
138 =item B<-W32[BL][0]>
139
140 UTF-32.
141 B or L gives whether Big Endian or Little Endian.
142 0 gives whther put BOM or not.
143
144 =back
145
146 =item B<-b -u>
147
148 Output is buffered (DEFAULT), Output is unbuffered.
149
150 =item B<-t>
151
152 No conversion.
153
154 =item B<-i[@B]>
155
156 Specify the escape sequence for JIS X 0208.
157
158 =over
159
160 =item B<-i@>
161
162 Use ESC ( @. (JIS X 0208-1978)
163
164 =item B<-iB>
165
166 Use ESC ( B. (JIS X 0208-1983/1990 DEFAULT)
167
168 =back
169
170 =item B<-o[BJ]>
171
172 Specify the escape sequence for US-ASCII/JIS X 0201 Roman. (DEFAULT B)
173
174 =item B<-r>
175
176 {de/en}crypt ROT13/47
177
178 =item B<-h[123] --hiragana --katakana --katakana-hiragana>
179
180 =over
181
182 =item B<-h1 --hiragana>
183
184 Katakana to Hiragana conversion.
185
186 =item B<-h2 --katakana>
187
188 Hiragana to Katakana conversion.
189
190 =item B<-h3 --katakana-hiragana>
191
192 Katakana to Hiragana and Hiragana to Katakana conversion.
193
194 =back
195
196 =item B<-T>
197
198 Text mode output (MS-DOS)
199
200 =item B<-l>
201
202 ISO8859-1 (Latin-1) support
203
204 =item B<-f[I<m> [- I<n>]]>
205
206 Folding on I<m> length with I<n> margin in a line.
207 Without this option, fold length is 60 and fold margin is 10.
208
209 =item B<-F>
210
211 New line preserving line folding.
212
213 =item B<-Z[0-3]>
214
215 Convert X0208 alphabet (Fullwidth Alphabets) to ASCII.
216
217 =over
218
219 =item B<-Z -Z0>
220
221 Convert X0208 alphabet to ASCII.
222
223 =item B<-Z1>
224
225 Convert X0208 kankaku to single ASCII space.
226
227 =item B<-Z2>
228
229 Convert X0208 kankaku to double ASCII spaces.
230
231 =item B<-Z3>
232
233 Replacing fullwidth >, <, ", & into '&gt;', '&lt;', '&quot;', '&amp;' as in HTML.
234
235 =back
236
237 =item B<-X -x>
238
239 Assume X0201 kana in MS-Kanji.
240 With B<-X> or without this option, X0201 is converted into X0208 Kana.
241 With B<-x>, try to preserve X0208 kana and do not convert X0201 kana to X0208.
242 In JIS output, ESC-(-I is used. In EUC output, SSO is used.
243
244 =item B<-B[0-2]>
245
246 Assume broken JIS-Kanji input, which lost ESC.
247 Useful when your site is using old B-News Nihongo patch.
248
249 =over
250
251 =item B<-B1>
252
253 allows any chars after ESC-( or ESC-$.
254
255 =item B<-B2>
256
257 force ASCII after NL.
258
259 =back
260
261 =item B<-I>
262
263 Replacing non iso-2022-jp char into a geta character
264 (substitute character in Japanese).
265
266 =item B<-m[BQN0]>
267
268 MIME ISO-2022-JP/ISO8859-1 decode. (DEFAULT)
269 To see ISO8859-1 (Latin-1) -l is necessary.
270
271 =over
272
273 =item B<-mB>
274
275 Decode MIME base64 encoded stream. Remove header or other part before
276 conversion. 
277
278 =item B<-mQ>
279
280 Decode MIME quoted stream. '_' in quoted stream is converted to space.
281
282 =item B<-mN>
283
284 Non-strict decoding.
285 It allows line break in the middle of the base64 encoding.
286
287 =item B<-m0>
288
289 No MIME decode.
290
291 =back
292
293 =item B<-M>
294
295 MIME encode. Header style. All ASCII code and control characters are intact.
296
297 =over
298
299 =item B<-MB>
300
301 MIME encode Base64 stream.
302 Kanji conversion is performed before encoding, so this cannot be used as a picture encoder.
303
304 =item B<-MQ>
305
306 Perform quoted encoding.
307
308 =back
309
310 =item B<-l>
311
312 Input and output code is ISO8859-1 (Latin-1) and ISO-2022-JP.
313 B<-s>, B<-e> and B<-x> are not compatible with this option.
314
315 =item B<-L[uwm] -d -c>
316
317 Convert line breaks.
318
319 =over
320
321 =item B<-Lu -d>
322
323 unix (LF)
324
325 =item B<-Lw -c>
326
327 windows (CRLF)
328
329 =item B<-Lm>
330
331 mac (CR)
332
333 Without this option, nkf doesn't convert line breaks.
334
335 =back
336
337 =item B<--fj --unix --mac --msdos --windows>
338
339 Convert for these systems.
340
341 =item B<--jis --euc --sjis --mime --base64>
342
343 Convert to named code.
344
345 =item B<--jis-input --euc-input --sjis-input --mime-input --base64-input>
346
347 Assume input system
348
349 =item B<--ic=I<input codeset> --oc=I<output codeset>>
350
351 Set the input or output codeset.
352 NKF supports following codesets and those codeset names are case insensitive.
353
354 =over
355
356 =item ISO-2022-JP
357
358 a.k.a. RFC1468, 7bit JIS, JUNET
359
360 =item EUC-JP (eucJP-nkf)
361
362 a.k.a. AT&T JIS, Japanese EUC, UJIS
363
364 =item eucJP-ascii
365
366 =item eucJP-ms
367
368 =item CP51932
369
370 Microsoft Version of EUC-JP.
371
372 =item Shift_JIS
373
374 a.k.a. SJIS, MS-Kanji
375
376 =item Windows-31J
377
378 a.k.a. CP932
379
380 =item UTF-8
381
382 same as UTF-8N
383
384 =item UTF-8N
385
386 UTF-8 without BOM
387
388 =item UTF-8-BOM
389
390 UTF-8 with BOM
391
392 =item UTF8-MAC (input only)
393
394 decomposed UTF-8
395
396 =item UTF-16
397
398 same as UTF-16BE
399
400 =item UTF-16BE
401
402 UTF-16 Big Endian without BOM
403
404 =item UTF-16BE-BOM
405
406 UTF-16 Big Endian with BOM
407
408 =item UTF-16LE
409
410 UTF-16 Little Endian without BOM
411
412 =item UTF-16LE-BOM
413
414 UTF-16 Little Endian with BOM
415
416 =item UTF-32
417
418 same as UTF-32BE
419
420 =item UTF-32BE
421
422 UTF-32 Big Endian without BOM
423
424 =item UTF-32BE-BOM
425
426 UTF-32 Big Endian with BOM
427
428 =item UTF-32LE
429
430 UTF-32 Little Endian without BOM
431
432 =item UTF-32LE-BOM
433
434 UTF-32 Little Endian with BOM
435
436 =back
437
438 =item B<--fb-{skip, html, xml, perl, java, subchar}>
439
440 Specify the way that nkf handles unassigned characters.
441 Without this option, --fb-skip is assumed.
442
443 =item B<--prefix=I<escape character>I<target character>..>
444
445 When nkf converts to Shift_JIS,
446 nkf adds a specified escape character to specified 2nd byte of Shift_JIS characters.
447 1st byte of argument is the escape character and following bytes are target characters.
448
449 =item B<--no-cp932ext>
450
451 Handle the characters extended in CP932 as unassigned characters.
452
453 =item B<--no-best-fit-chars>
454
455 When Unicode to Encoded byte conversion,
456 don't convert characters which is not round trip safe.
457 When Unicode to Unicode conversion,
458 with this and -x option, nkf can be used as UTF converter.
459 (In other words, without this and -x option, nkf doesn't save some characters)
460
461 When nkf converts strings that related to path, you should use this opion.
462
463 =item B<--cap-input>
464
465 Decode hex encoded characters.
466
467 =item B<--url-input>
468
469 Unescape percent escaped characters.
470
471 =item B<--numchar-input>
472
473 Decode character reference, such as "&#....;".
474
475 =begin COMMAND
476
477 =item B<--in-place[=>I<SUFFIX>B<]>  B<--overwrite[=>I<SUFFIX>B<]>
478
479 Overwrite B<original> listed files by filtered result.
480
481 B<Note> --overwrite preserves timestamps of original files.
482
483 =item B<--guess=[12]>
484
485 Print guessed encoding and newline. (2 is default, 1 is only encoding)
486
487 =item B<--help>
488
489 Print nkf's help.
490
491 =item B<--version>
492
493 Print nkf's version.
494
495 =end
496
497 =item B<-->
498
499 Ignore rest of -option.
500
501 =back
502
503 =head1 AUTHOR
504
505 Copyright (c) 1987, Fujitsu LTD. (Itaru ICHIKAWA).
506
507 Copyright (c) 1996-2009, The nkf Project.
508
509 =begin
510
511 =head1 SEE ALSO
512
513 perl(1).   nkf(1)
514
515 =end
516
517 =cut