1 # Copyright (c) 1987, Fujitsu LTD. (Itaru ICHIKAWA).
2 # Copyright (c) 1996-2009, The nkf Project.
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.
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:
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.
18 # 2. Altered source versions must be plainly marked as such, and must not be
19 # misrepresented as being the original software.
21 # 3. This notice may not be removed or altered from any source distribution.
26 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
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.
36 nkf nkf_continue inputcode
40 bootstrap NKF $VERSION;
42 # Preloaded methods go here.
44 # Autoload methods go after =cut, and are processed by the autosplit program.
50 # =begin ¤«¤é =begin COMMAND ¤Þ¤Ç¤Ï Perl/NKF ¤Î¥É¥¥å¥á¥ó¥È
51 # =begin COMMAND ¤«¤é =end ¤Þ¤Ç¤Ï nkf ¥³¥Þ¥ó¥É¤Î¥É¥¥å¥á¥ó¥È
58 NKF - Perl extension for Network Kanji Filter
62 nkf - Network Kanji Filter
71 $output = nkf("-s",$input);
75 nkf B<[-butjnesliohrTVvwWJESZxXFfmMBOcdILg]> B<[>I<file ...>B<]>
83 This is a Perl Extension version of nkf (Network Kanji Filter).
84 It converts the last argument and return converted result. Conversion
85 details are specified by flags before the last argument.
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.
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.
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>.
106 =item B<-J -S -E -W -W16 -W32 -j -s -e -w -w16 -w32>
108 Specify input and output encodings. Upper case is input.
115 ISO-2022-JP (JIS code).
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).
135 B or L gives whether Big Endian or Little Endian.
136 0 gives whther put BOM or not.
141 B or L gives whether Big Endian or Little Endian.
142 0 gives whther put BOM or not.
148 Output is buffered (DEFAULT), Output is unbuffered.
156 Specify the escape sequence for JIS X 0208.
162 Use ESC ( @. (JIS X 0208-1978)
166 Use ESC ( B. (JIS X 0208-1983/1990 DEFAULT)
172 Specify the escape sequence for US-ASCII/JIS X 0201 Roman. (DEFAULT B)
176 {de/en}crypt ROT13/47
178 =item B<-h[123] --hiragana --katakana --katakana-hiragana>
182 =item B<-h1 --hiragana>
184 Katakana to Hiragana conversion.
186 =item B<-h2 --katakana>
188 Hiragana to Katakana conversion.
190 =item B<-h3 --katakana-hiragana>
192 Katakana to Hiragana and Hiragana to Katakana conversion.
198 Text mode output (MS-DOS)
202 ISO8859-1 (Latin-1) support
204 =item B<-f[I<m> [- I<n>]]>
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.
211 New line preserving line folding.
215 Convert X0208 alphabet (Fullwidth Alphabets) to ASCII.
221 Convert X0208 alphabet to ASCII.
225 Convert X0208 kankaku to single ASCII space.
229 Convert X0208 kankaku to double ASCII spaces.
233 Replacing fullwidth >, <, ", & into '>', '<', '"', '&' as in HTML.
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.
246 Assume broken JIS-Kanji input, which lost ESC.
247 Useful when your site is using old B-News Nihongo patch.
253 allows any chars after ESC-( or ESC-$.
257 force ASCII after NL.
263 Replacing non iso-2022-jp char into a geta character
264 (substitute character in Japanese).
268 MIME ISO-2022-JP/ISO8859-1 decode. (DEFAULT)
269 To see ISO8859-1 (Latin-1) -l is necessary.
275 Decode MIME base64 encoded stream. Remove header or other part before
280 Decode MIME quoted stream. '_' in quoted stream is converted to space.
285 It allows line break in the middle of the base64 encoding.
295 MIME encode. Header style. All ASCII code and control characters are intact.
301 MIME encode Base64 stream.
302 Kanji conversion is performed before encoding, so this cannot be used as a picture encoder.
306 Perform quoted encoding.
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.
315 =item B<-L[uwm] -d -c>
333 Without this option, nkf doesn't convert line breaks.
337 =item B<--fj --unix --mac --msdos --windows>
339 Convert for these systems.
341 =item B<--jis --euc --sjis --mime --base64>
343 Convert to named code.
345 =item B<--jis-input --euc-input --sjis-input --mime-input --base64-input>
349 =item B<--ic=I<input codeset> --oc=I<output codeset>>
351 Set the input or output codeset.
352 NKF supports following codesets and those codeset names are case insensitive.
358 a.k.a. RFC1468, 7bit JIS, JUNET
360 =item EUC-JP (eucJP-nkf)
362 a.k.a. AT&T JIS, Japanese EUC, UJIS
370 Microsoft Version of EUC-JP.
374 a.k.a. SJIS, MS-Kanji
392 =item UTF8-MAC (input only)
402 UTF-16 Big Endian without BOM
406 UTF-16 Big Endian with BOM
410 UTF-16 Little Endian without BOM
414 UTF-16 Little Endian with BOM
422 UTF-32 Big Endian without BOM
426 UTF-32 Big Endian with BOM
430 UTF-32 Little Endian without BOM
434 UTF-32 Little Endian with BOM
438 =item B<--fb-{skip, html, xml, perl, java, subchar}>
440 Specify the way that nkf handles unassigned characters.
441 Without this option, --fb-skip is assumed.
443 =item B<--prefix=I<escape character>I<target character>..>
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.
449 =item B<--no-cp932ext>
451 Handle the characters extended in CP932 as unassigned characters.
453 =item B<--no-best-fit-chars>
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)
461 When nkf converts strings that related to path, you should use this opion.
465 Decode hex encoded characters.
469 Unescape percent escaped characters.
471 =item B<--numchar-input>
473 Decode character reference, such as "&#....;".
477 =item B<--in-place[=>I<SUFFIX>B<]> B<--overwrite[=>I<SUFFIX>B<]>
479 Overwrite B<original> listed files by filtered result.
481 B<Note> --overwrite preserves timestamps of original files.
483 =item B<--guess=[12]>
485 Print guessed encoding and newline. (2 is default, 1 is only encoding)
499 Ignore rest of -option.
505 Copyright (c) 1987, Fujitsu LTD. (Itaru ICHIKAWA).
507 Copyright (c) 1996-2009, The nkf Project.