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 (Netowrk 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 or UTF-16.
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.
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>.
108 Output is buffered (DEFAULT), Output is unbuffered.
110 =item B<-j -s -e -w -w16>
112 Output code is ISO-2022-JP (7bit JIS), Shift_JIS, EUC-JP,
114 Without this option and compile option, ISO-2022-JP is assumed.
116 =item B<-J -S -E -W -W16>
118 Input assumption is JIS 7 bit, Shift_JIS, EUC-JP,
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.
146 Specify the escape sequence for JIS X 0208.
152 Use ESC ( @. (JIS X 0208-1978)
156 Use ESC ( B. (JIS X 0208-1983/1990 DEFAULT)
160 Specify the escape sequence for US-ASCII/JIS X 0201 Roman. (DEFAULT B)
164 {de/en}crypt ROT13/47
166 =item B<-h[123] --hiragana --katakana --katakana-hiragana>
170 =item B<-h1 --hiragana>
172 Katakana to Hiragana conversion.
174 =item B<-h2 --katakana>
176 Hiragana to Katakana conversion.
178 =item B<-h3 --katakana-hiragana>
180 Katakana to Hiragana and Hiragana to Katakana conversion.
186 Text mode output (MS-DOS)
190 ISO8859-1 (Latin-1) support
192 =item B<-f[I<m> [- I<n>]]>
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.
199 New line preserving line folding.
203 Convert X0208 alphabet (Fullwidth Alphabets) to ASCII.
209 Convert X0208 alphabet to ASCII.
213 Convert X0208 kankaku to single ASCII space.
217 Convert X0208 kankaku to double ASCII spaces.
221 Replacing fullwidth >, <, ", & into '>', '<', '"', '&' as in HTML.
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.
234 Assume broken JIS-Kanji input, which lost ESC.
235 Useful when your site is using old B-News Nihongo patch.
241 allows any chars after ESC-( or ESC-$.
245 force ASCII after NL.
251 Replacing non iso-2022-jp char into a geta character
252 (substitute character in Japanese).
256 MIME ISO-2022-JP/ISO8859-1 decode. (DEFAULT)
257 To see ISO8859-1 (Latin-1) -l is necessary.
263 Decode MIME base64 encoded stream. Remove header or other part before
268 Decode MIME quoted stream. '_' in quoted stream is converted to space.
273 It allows line break in the middle of the base64 encoding.
283 MIME encode. Header style. All ASCII code and control characters are intact.
289 MIME encode Base64 stream.
290 Kanji conversion is performed before encoding, so this cannot be used as a picture encoder.
294 Perform quoted encoding.
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.
303 =item B<-L[uwm] -d -c>
321 Without this option, nkf doesn't convert line breaks.
325 =item B<--fj --unix --mac --msdos --windows>
327 Convert for these systems.
329 =item B<--jis --euc --sjis --mime --base64>
331 Convert to named code.
333 =item B<--jis-input --euc-input --sjis-input --mime-input --base64-input>
337 =item B<--ic=I<input codeset> --oc=I<output codeset>>
339 Set the input or output codeset.
340 NKF supports following codesets and those codeset names are case insensitive.
346 a.k.a. RFC1468, 7bit JIS, JUNET
348 =item EUC-JP (eucJP-nkf)
350 a.k.a. AT&T JIS, Japanese EUC, UJIS
358 Microsoft Version of EUC-JP.
362 a.k.a. SJIS, MS-Kanji
380 =item UTF8-MAC (input only)
390 UTF-16 Big Endian without BOM
394 UTF-16 Big Endian with BOM
398 UTF-16 Little Endian without BOM
402 UTF-16 Little Endian with BOM
406 =item B<--fb-{skip, html, xml, perl, java, subchar}>
408 Specify the way that nkf handles unassigned characters.
409 Without this option, --fb-skip is assumed.
411 =item B<--prefix=I<escape character>I<target character>..>
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.
417 =item B<--no-cp932ext>
419 Handle the characters extended in CP932 as unassigned characters.
421 =item B<--no-best-fit-chars>
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)
429 When nkf converts strings that related to path, you should use this opion.
433 Decode hex encoded characters.
437 Unescape percent escaped characters.
439 =item B<--numchar-input>
441 Decode character reference, such as "&#....;".
445 =item B<--in-place[=>I<SUFFIX>B<]> B<--overwrite[=>I<SUFFIX>B<]>
447 Overwrite B<original> listed files by filtered result.
449 B<Note> --overwrite preserves timestamps of original files.
451 =item B<--guess=[12]>
453 Print guessed encoding and newline. (2 is default, 1 is only encoding)
467 Ignore rest of -option.
473 Copyright (c) 1987, Fujitsu LTD. (Itaru ICHIKAWA).
475 Copyright (c) 1996-2009, The nkf Project. http://sourceforge.jp/projects/nkf