nkf(1)
π nkf β the Network Kanji Filter, bestie edition π
okay so. <pink>nkf(1)</pink>? That's the manual page for nkf, the Network Kanji Filter. It's a kanji code converter and honestly it's been carrying the whole encoding situation on its back since before we were born. Come sit, I'll walk you through it π«Ά
β¨ NAME β¨
nkf β Network Kanji Filter. That's it, that's the name, iconic, no notes π
β¨ SYNOPSIS β¨
nkf [-butjnesliohrTVvwWJESZxXFfmMBOcdILg] [file ...]
β¨ DESCRIPTION β¨
So <purple>nkf</purple> is yet another kanji code converter between networks, hosts and terminals. Yeah, "yet another", they said it themselves, we're keeping it real. It takes your input kanji code and flips it into whichever kanji code you designate β things like ISO-2022-JP, Shift_JIS, EUC-JP, UTF-8, UTF-16 or UTF-32. The range? Immaculate. β¨
One of nkf's most unique faculties β and honestly its main character trait β is that it guesses the input kanji encodings. It currently recognizes ISO-2022-JP, Shift_JIS, EUC-JP, UTF-8, UTF-16 and UTF-32. So you don't gotta set the input kanji code explicitly. It just knows. π₯
By default, X0201 kana gets converted into X0208 kana. For X0201 kana, the SO/SI, SSO and ESC-(-I methods are all supported. But heads up: for automatic code detection, nkf assumes there's no X0201 kana in Shift_JIS. If you want to accept X0201 in Shift_JIS, use -X, -x or -S. π
Also, multiple options are specified as separate strings, like this:
print nkf('--ic=UTF8-MAC', '-w', $string), "\n";
β¦except the last arguments. yeah. that's the rule. π
β¨ OPTIONS β¨
This is the long part, bestie. Grab a snack. Every single flag is here, I promise. π
-J-S-E-W-W16-W32-j-s-e-w-w16-w32β specify input and output encodings. Upper case is input. cf.--icand--oc.-Jβ ISO-2022-JP (JIS code).-Sβ Shift_JIS and JIS X 0201 kana. EUC-JP is recognized as X0201 kana. Without the-xflag, JIS X 0201 Katakana (a.k.a. halfwidth kana) is converted into JIS X 0208. If you use Windows, see Windows-31J (CP932).-Eβ EUC-JP.-Wβ UTF-8N.-W16[BL][0]β UTF-16.BorLsays whether it's Big Endian or Little Endian.0says whether to put a BOM or not.-W32[BL][0]β UTF-32.BorLsays whether it's Big Endian or Little Endian.0says whether to put a BOM or not.
-b-uβ output is buffered (this is the DEFAULT), and output is unbuffered. respectively π-tβ no conversion. we're just vibing. no thoughts, head empty, bytes unchanged.-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 isB)-rβ {de/en}crypt ROT13/47. sneaky. love that for us. π΅οΈ-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. both directions, greedy, obsessed π
-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'>','<','"','&'as in HTML.
-X-xβ With-Xor 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-(-Iis used. In EUC output,SS2is used.-B[0-2]β Assume broken JIS-Kanji input, which lost ESC. Useful when your site is using old B-News Nihongo patch. (ngl that's a whole historical artifact, respect π«‘)-B1β allows any chars afterESC-(orESC-$.-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),-lis necessary.-mBβ Decode MIME base64 encoded stream. Remove header or other part before conversion.-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. like, don't try it. it will not eat. π-MQβ Perform quoted encoding.
-lβ Input and output code is ISO8859-1 (Latin-1) and ISO-2022-JP.-s,-eand-xare 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. it minds its business. β¨
--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 the following codesets, and those codeset names are case insensitive. πISO-2022-JPβ a.k.a. RFC1468, 7bit JIS, JUNETEUC-JP(eucJP-nkf) β a.k.a. AT&T JIS, Japanese EUC, UJISeucJP-asciieucJP-msCP51932β Microsoft Version of EUC-JP.Shift_JISβ a.k.a. SJIS, MS_KanjiWindows-31Jβ a.k.a. CP932UTF-8β same as UTF-8NUTF-8Nβ UTF-8 without BOMUTF-8-BOMβ UTF-8 with BOMUTF8-MAC(input only) β decomposed UTF-8UTF-16β same as UTF-16BEUTF-16BEβ UTF-16 Big Endian without BOMUTF-16BE-BOMβ UTF-16 Big Endian with BOMUTF-16LEβ UTF-16 Little Endian without BOMUTF-16LE-BOMβ UTF-16 Little Endian with BOMUTF-32β same as UTF-32BEUTF-32BEβ UTF-32 Big Endian without BOMUTF-32BE-BOMβ UTF-32 Big Endian with BOMUTF-32LEβ UTF-32 Little Endian without BOMUTF-32LE-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-skipis 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. The 1st byte of the 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 the-xoption, nkf can be used as UTF converter. (In other words, without this and-xoption, 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. (2is default,1is only encoding)--helpβ Print nkf's help.--versionβ Print nkf's version.--β Ignore rest of-option.
β¨ AUTHOR β¨
Copyright (c) 1987, Fujitsu LTD. (Itaru ICHIKAWA).
Copyright (c) 1996-2018, The nkf Project.
and that's the whole page, bestie!! π you made it, you absolute legend, main character energy fr fr. go forth and convert some kanji, slay β¨π¦πΈ
this has been nkf 2.1.5, dated 2018-12-15, and yeah the manual is literally just called nkf(1). bye bestie!! πππ
π¦ where this page comes from
- debian bookworm: nkf 1:2.1.5-1+b5 Β· Custom
- debian trixie: nkf 1:2.1.5-1+b8 Β· Custom
- ubuntu jammy: nkf 1:2.1.5-1build3 Β· Custom
- ubuntu noble: nkf 1:2.1.5-1build7 Β· Custom
- ubuntu questing: nkf 1:2.1.5-1build8
- ubuntu resolute: nkf 1:2.1.5-1.1 Β· Custom
- ubuntu stonking: nkf 1:2.1.5-1.1build1 Β· Custom
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms