OSDN Git Service

* Add document about --hiragana and some fixes.
[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.05';
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 # Below is the stub of documentation for your module. You better edit it!
50
51 =head1 NAME
52
53 NKF - Perl extension for Network Kanji Filter 
54
55 =head1 SYNOPSIS
56
57   use NKF;
58   $output = nkf("-s",$input);
59
60 =head1 DESCRIPTION
61
62 This is a Perl Extension version of nkf (Netowrk Kanji Filter).
63 It converts the last argument and return converted result. Conversion
64 details are specified by flags before the last argument.
65
66
67 B<Nkf> is a yet another kanji code converter among networks, hosts and terminals.
68 It converts input kanji code to designated kanji code
69 such as ISO-2022-JP, Shift_JIS, EUC-JP, UTF-8 or UTF-16.
70
71 One of the most unique faculty of B<nkf> is the guess of the input kanji encodings.
72 It currently recognizes ISO-2022-JP, Shift_JIS, EUC-JP, UTF-8 and UTF-16.
73 So users needn't set the input kanji code explicitly.
74
75 By default, X0201 kana is converted into X0208 kana.
76 For X0201 kana, SO/SI, SSO and ESC-(-I methods are supported.
77 For automatic code detection, nkf assumes no X0201 kana in Shift_JIS.
78 To accept X0201 in Shift_JIS, use B<-X>, B<-x> or B<-S>.
79
80 =head1 Flags
81
82 =over
83
84 =item B<-b -u>
85
86 Output is bufferred (DEFAULT),Output is unbufferred
87
88 =item B<-j -s -e -w -w16>
89
90 Outout code is ISO-2022-JP (7bit JIS), Shift_JIS, EUC-JP,
91 UTF-8N, UTF-16BE.
92 Without this option and compile option, ISO-2022-JP is assumed.
93
94 =item B<-J -S -E -W -W16>
95
96 Input assumption is JIS 7 bit , Shift_JIS, EUC-JP,
97 UTF-8, UTF-16LE.
98
99 =over
100
101 =item B<-J>
102
103 Assume  JIS input. It also accepts EUC-JP.
104 This is the default. This flag does not exclude Shift_JIS.
105
106 =item B<-S>
107
108 Assume Shift_JIS and X0201 kana input. It also accepts JIS.
109 EUC-JP is recognized as X0201 kana. Without B<-x> flag,
110 X0201 kana (halfwidth kana) is converted into X0208.
111
112 =item B<-E>
113
114 Assume EUC-JP input. It also accepts JIS.
115 Same as -J.
116
117 =back
118
119 =item B<-t>
120
121 no conversion
122
123 =item B<-i_>
124
125 Output sequence to designate JIS-kanji (DEFAULT B)
126
127 =item B<-o_>
128
129 Output sequence to designate ASCII (DEFAULT B)
130
131 =item B<-r>
132
133 {de/en}crypt ROT13/47
134
135 =item B<-h[123] --hiragana --katakana --katakana-hiragana>
136
137 =over
138
139 =item B<-h1 --hiragana>
140
141 Katakana to Hiragana convertion
142
143 =item B<-h2 --katakana>
144
145 Hiragana to Katakana convertion
146
147 =item B<-h3 --katakana-hiragana>
148
149 Katakana to Hiragana and Hiragana to Katakana convertion
150
151 =back
152
153 =item B<-T>
154 Text mode output (MS-DOS)
155
156 =item B<-l>
157
158 ISO8859-1 (Latin-1) support
159
160 =item B<-f[I<m> [- I<n>]]>
161
162 Folding on I<m> length with I<n> margin in a line.
163 Without this option, fold length is 60 and fold margin is 10.
164
165 =item B<-F>
166
167 New line preserving line folding.
168
169 =item B<-Z[0-3]>
170
171 Convert X0208 alphabet (Fullwidth Alphabets) to ASCII.
172
173 =over
174
175 =item B<-Z -Z0>
176
177 Convert X0208 alphabet to ASCII.
178
179 =item B<-Z1>
180
181 converts X0208 kankaku to single ASCII space.
182
183 =item B<-Z2>
184
185 converts X0208 kankaku to double ASCII spaces.
186
187 =item B<-Z3>
188
189 Replacing Fullwidth >, <, ", & into '&gt;', '&lt;', '&quot;', '&amp;' as in HTML.
190
191 =back
192
193 =item B<-X -x>
194
195 Assume X0201 kana in MS-Kanji.
196 With B<-X> or without this option, X0201 is converted into X0208 Kana.
197 With B<-x>, try to preseve X0208 kana and do not convert X0201 kana to X0208.
198 In JIS output, ESC-(-I is used. In EUC output, SSO is used.
199
200 =item B<-B[0-2]>
201
202 Assume broken JIS-Kanji input, which lost ESC.
203 Useful when your site is using old B-News Nihongo patch.
204
205 =over
206
207 =item B<-B1>
208
209 allows any char after ESC-( or ESC-$.
210
211 =item B<-B2>
212
213 forces ASCII after NL.
214
215 =back
216
217 =item B<-I>
218
219 Replacing non iso-2022-jp char into a geta character
220 (substitute character in Japanese).
221
222 =item B<-d -c>
223
224 Delete \r in line feed, Add \r in line feed
225
226 =item B<-m[BQN0]>
227
228 MIME ISO-2022-JP/ISO8859-1 decode. (default)
229 To see ISO8859-1 (Latin-1) -l is necessary.
230
231 =over
232
233 =item B<-mB>
234
235 Decode MIME base64 encoded stream. Remove header or other part before
236 conversion. 
237
238 =item B<-mQ>
239
240 Decode MIME quoted stream. '_' in quoted stream is converted to space.
241
242 =item B<-mN>
243
244 Non-strict decoding.
245 It allows line break in the middle of the base64 encoding.
246
247 =item B<-m0>
248
249 No MIME decode.
250
251 =back
252
253 =item B<-M>
254
255 MIME encode. Header style. All ASCII code and control characters are intact.
256
257 =over
258
259 =item B<-MB>
260
261 MIME encode Base64 stream.
262 Kanji conversion is performed before encoding, so this cannot be used as a picture encoder.
263
264 =item B<-MQ>
265
266 perfome quoted encoding.
267
268 =back
269
270 =item B<-l>
271
272 Input and output code is ISO8859-1 (Latin-1) and ISO-2022-JP.
273 B<-s>, B<-e> and B<-x> are not compatible with this option.
274
275 =item B<-L[wmu]>
276
277 new line mode
278
279 =over
280
281 =item B<-Lu>
282
283 unix (LF)
284
285 =item B<-Lw>
286
287 windows (CRLF)
288
289 =item B<-Lm>
290
291 mac (CR)
292
293 Without this option, nkf doesn't convert line breaks.
294
295 =back
296
297 =item B<--fj --unix --mac --msdos --windows>
298
299 convert for these system
300
301 =item B<--jis --euc --sjis --mime --base64>
302
303 convert for named code
304
305 =item B<--jis-input --euc-input --sjis-input --mime-input --base64-input>
306
307 assume input system
308
309 =item B<--ic=I<input codeset> --oc=I<output codeset>>
310
311 Set the input or output codeset.
312 NKF supports following codesets and those codeset name are case insensitive.
313
314 =over
315
316 =item ISO-2022-JP
317
318 a.k.a. RFC1468, 7bit JIS, JUNET
319
320 =item EUC-JP (eucJP-nkf)
321
322 a.k.a. AT&T JIS, Japanese EUC, UJIS
323
324 =item eucJP-ascii
325
326 =item eucJP-ms
327
328 =item CP51932
329
330 Microsoft Version of EUC-JP.
331
332 =item Shift_JIS
333
334 a.k.a. SJIS, MS-Kanji
335
336 =item CP932
337
338 a.k.a. Windows-31J
339
340 =item UTF-8
341
342 same as UTF-8N
343
344 =item UTF-8N
345
346 UTF-8 without BOM
347
348 =item UTF-8-BOM
349
350 UTF-8 with BOM
351
352 =item UTF-16
353
354 same as UTF-16BE
355
356 =item UTF-16BE
357
358 UTF-16 Big Endian without BOM
359
360 =item UTF-16BE-BOM
361
362 UTF-16 Big Endian with BOM
363
364 =item UTF-16LE
365
366 UTF-16 Little Endian without BOM
367
368 =item UTF-16LE-BOM
369
370 UTF-16 Little Endian with BOM
371
372 =item UTF8-MAC (input only)
373
374 =back
375
376 =item B<--fb-{skip, html, xml, perl, java, subchar}>
377
378 Specify the way that nkf handles unassigned characters.
379 Without this option, --fb-skip is assumed.
380
381 =item B<--prefix=I<escape character>I<target character>..>
382
383 When nkf converts to Shift_JIS,
384 nkf adds a specified escape character to specified 2nd byte of Shift_JIS characters.
385 1st byte of argument is the escape character and following bytes are target characters.
386
387 =item B<--disable-cp932ext>
388
389 Handle the characters extended in CP932 as unassinged characters.
390
391 =item B<--cap-input>
392
393 Decode hex encoded characters.
394
395 =item B<--url-input>
396
397 Unescape percent escaped characters.
398
399 =item B<-->
400
401 ignore rest of -option
402
403 =back
404
405 =head1 AUTHOR
406
407 Network Kanji Filter Version 2.0.5
408
409 Copyright (C) 1987, FUJITSU LTD. (I.Ichikawa),2000 S. Kono, COW, 2002-2005 Kono, Furukawa, Naruse
410
411 =head1 SEE ALSO
412
413 perl(1).   nkf(1)
414
415 =cut