• R/O
  • HTTP
  • SSH

nkf: レポジトリ概要


最近のコミット RSS

Rev. 日時 作者 メッセージ
a4f55f2 2022-03-15 13:48:11 NARUSE, Yui master Merge pull request #8 from slic-io/devlop fix: python3 ...
8246108 2022-03-06 18:05:54 slic fix: python3 extention ABI # variant when parsing warning
500dcf2 2019-06-12 16:31:35 NARUSE, Yui Merge pull request #7 from conao3/fix-mkdir-option Add ...
d668c67 2019-06-10 21:03:13 conao3 use xargs not to use backquote shell execution
1a7d288 2019-06-10 00:18:54 conao3 changed test mkdir directory from /tmp to pwd This makes...
6eca8e9 2019-06-10 00:10:56 conao3 enable -p option when mkdir definitely has
9ccff59 2019-06-09 01:52:05 conao3 Add -p option for mkdir to suppress error. Compiling nkf...
b17db8a 2019-02-18 07:47:56 NARUSE, Yui Add description about --overwrite and --in-place fix htt...
75230cc 2019-02-18 07:36:35 Kazuhiro Sera Add generated files by 'make test && make perl && make py...
7be89de 2019-02-18 07:36:35 Kazuhiro Sera Fix typos


名前 Rev. 日時 作者
v2_1_5 08043ea 2018-12-15 18:19:02 NARUSE, Yui
v2.1.4.1 101275c 2017-07-23 00:57:47 Kazuhiro Kato
v2_1_4 5047050 2015-12-12 22:31:34 NARUSE, Yui
v2_1_3 2a2f2c5 2013-11-22 14:14:37 NARUSE, Yui
v2_1_0 3d0cc48 2009-11-17 09:31:43 NARUSE Yui
v2_0_9 c5c9aeb 2009-01-20 17:34:56 NARUSE, Yui
v2_0_8 18ec093 2007-07-10 03:11:57 NARUSE, Yui
v2_0_7 367e8d5 2006-06-13 11:08:20 NARUSE, Yui
v2_0_6_beta2 7b023c4 2006-03-25 00:14:32 NARUSE, Yui
nkf-202 8b6759f 2003-01-25 18:13:24 Rei FURUKAWA


名前 Rev. 日時 作者 メッセージ
master a4f55f2 2022-03-15 13:48:11 NARUSE, Yui Merge pull request #8 from...



nkf - Network Kanji Filter


nkf [-butjnesliohrTVvwWJESZxXFfmMBOcdILg] [___file ...___]


Nkf is a yet another kanji code converter among networks, hosts and terminals. It converts input kanji code to designated kanji code such as ISO-2022-JP, Shift_JIS, EUC-JP, UTF-8, UTF-16 or UTF-32.

One of the most unique faculty of nkf is the guess of the input kanji encodings. It currently recognizes ISO-2022-JP, Shift_JIS, EUC-JP, UTF-8, UTF-16 and UTF-32. So users needn't set the input kanji code explicitly.

By default, X0201 kana is converted into X0208 kana. For X0201 kana, SO/SI, SSO and ESC-(-I methods are supported. For automatic code detection, nkf assumes no X0201 kana in Shift_JIS. To accept X0201 in Shift_JIS, use -X, -x or -S.


  • -J -S -E -W -W16 -W32 -j -s -e -w -w16 -w32

Specify input and output encodings. Upper case is input. cf. --ic and --oc.

- __-J__

ISO-2022-JP (JIS code).

- __-S__

Shift_JIS and JIS X 0201 kana.
EUC-JP is recognized as X0201 kana. Without __-x__ flag,
JIS X 0201 Katakana (a.k.a.halfwidth kana) is converted into JIS X 0208.
If you use Windows, see Windows-31J (CP932).

- __-E__


- __-W__


- __-W16[BL][0]__

B or L gives whether Big Endian or Little Endian.
0 gives whether put BOM or not.

- __-W32[BL][0]__

B or L gives whether Big Endian or Little Endian.
0 gives whether put BOM or not.
  • -b -u

Output is buffered (DEFAULT), Output is unbuffered.

  • -t

No conversion.

  • -i[@B]

Specify the escape sequence for JIS X 0208.

- __-i@__

Use ESC ( @. (JIS X 0208-1978)

- __-iB__

Use ESC ( B. (JIS X 0208-1983/1990 DEFAULT)
  • -o[BJ]

Specify the escape sequence for US-ASCII/JIS X 0201 Roman. (DEFAULT B)

  • -r

{de/en}crypt ROT13/47

- __-h[123] --hiragana --katakana --katakana-hiragana__
- __-h1 --hiragana__

Katakana to Hiragana conversion.

- __-h2 --katakana__

Hiragana to Katakana conversion.

- __-h3 --katakana-hiragana__

Katakana to Hiragana and Hiragana to Katakana conversion.
  • -T

Text mode output (MS-DOS)

  • -f[m [- n]]

Folding on m length with n margin in a line. Without this option, fold length is 60 and fold margin is 10.

  • -F

New line preserving line folding.

  • -Z[0-3]

Convert X0208 alphabet (Fullwidth Alphabets) to ASCII.

- __-Z -Z0__

Convert X0208 alphabet to ASCII.

- __-Z1__

Convert X0208 kankaku to single ASCII space.

- __-Z2__

Convert X0208 kankaku to double ASCII spaces.

- __-Z3__

Replacing fullwidth >, <, ", & into '&gt;', '&lt;', '&quot;', '&amp;' as in HTML.
  • -X -x

With -X or without this option, X0201 is converted into X0208 Kana. With -x, try to preserve X0208 kana and do not convert X0201 kana to X0208. In JIS output, ESC-(-I is used. In EUC output, SS2 is used.

  • -B[0-2]

Assume broken JIS-Kanji input, which lost ESC. Useful when your site is using old B-News Nihongo patch.

- __-B1__

allows any chars after ESC-( or ESC-$.

- __-B2__

force ASCII after NL.
  • -I

Replacing non iso-2022-jp char into a geta character (substitute character in Japanese).

  • -m[BQN0]

MIME ISO-2022-JP/ISO8859-1 decode. (DEFAULT) To see ISO8859-1 (Latin-1) -l is necessary.

- __-mB__

Decode MIME base64 encoded stream. Remove header or other part before

- __-mQ__

Decode MIME quoted stream. '_' in quoted stream is converted to space.

- __-mN__

Non-strict decoding.
It allows line break in the middle of the base64 encoding.

- __-m0__

No MIME decode.
  • -M

MIME encode. Header style. All ASCII code and control characters are intact.

- __-MB__

MIME encode Base64 stream.
Kanji conversion is performed before encoding, so this cannot be used as a picture encoder.

- __-MQ__

Perform quoted encoding.
  • -l

Input and output code is ISO8859-1 (Latin-1) and ISO-2022-JP. -s, -e and -x are not compatible with this option.

  • -L[uwm] -d -c

Convert line breaks.

- __-Lu -d__

unix (LF)

- __-Lw -c__

windows (CRLF)

- __-Lm__

mac (CR)

Without this option, nkf doesn't convert line breaks.
  • --fj --unix --mac --msdos --windows

Convert for these systems.

  • --jis --euc --sjis --mime --base64

Convert to named code.

  • --jis-input --euc-input --sjis-input --mime-input --base64-input

Assume input system

  • --ic=input codeset --oc=output codeset

Set the input or output codeset. NKF supports following codesets and those codeset names are case insensitive.

- ISO-2022-JP

a.k.a. RFC1468, 7bit JIS, JUNET

- EUC-JP (eucJP-nkf)

a.k.a. AT&T JIS, Japanese EUC, UJIS

        - eucJP-ascii
    - eucJP-ms
- CP51932

Microsoft Version of EUC-JP.

- Shift_JIS

a.k.a. SJIS, MS_Kanji

- Windows-31J

a.k.a. CP932

- UTF-8

same as UTF-8N

- UTF-8N

UTF-8 without BOM


UTF-8 with BOM

- UTF8-MAC (input only)

decomposed UTF-8

- UTF-16

same as UTF-16BE

- UTF-16BE

UTF-16 Big Endian without BOM


UTF-16 Big Endian with BOM

- UTF-16LE

UTF-16 Little Endian without BOM


UTF-16 Little Endian with BOM

- UTF-32

same as UTF-32BE

- UTF-32BE

UTF-32 Big Endian without BOM


UTF-32 Big Endian with BOM

- UTF-32LE

UTF-32 Little Endian without BOM


UTF-32 Little Endian with BOM
  • --fb-{skip, html, xml, perl, java, subchar}

Specify the way that nkf handles unassigned characters. Without this option, --fb-skip is assumed.

  • --prefix=escape character__target character..

When nkf converts to Shift_JIS, nkf adds a specified escape character to specified 2nd byte of Shift_JIS characters. 1st byte of argument is the escape character and following bytes are target characters.

  • --no-cp932ext

Handle the characters extended in CP932 as unassigned characters.

  • --no-best-fit-chars

When Unicode to Encoded byte conversion, don't convert characters which is not round trip safe. When Unicode to Unicode conversion, with this and -x option, nkf can be used as UTF converter. (In other words, without this and -x option, nkf doesn't save some characters)

When nkf converts strings that related to path, you should use this option.

  • --cap-input

Decode hex encoded characters.

  • --url-input

Unescape percent escaped characters.

  • --numchar-input

Decode character reference, such as "&#....;".

  • --in-place[=___SUFFIX___] --overwrite[=___SUFFIX___]

Overwrite original listed files by filtered result.

Note --overwrite preserves timestamps of original files.

  • --guess=[12]

Print guessed encoding and newline. (2 is default, 1 is only encoding)

  • --help

Print nkf's help.

  • --version

Print nkf's version.

  • --

Ignore rest of -option.


Copyright (c) 1987, Fujitsu LTD. (Itaru ICHIKAWA).

Copyright (c) 1996-2012, The nkf Project.