OSDN Git Service

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