NKF(3pm)

๐Ÿ’– NAME ๐Ÿ’–

okay so bestie, welcome to NKF(3pm) ๐Ÿ’… this is the page for nkf โ€” a kanji code converter that hops between networks, hosts and terminals โ€” as it shows up in the Perl world (see the little nkf(...) call down below, iykyk). Sit down, grab a strawberry ๐Ÿ“, and let's get you fluent.


โœจ SYNOPSIS โœจ

ngl there's no big synopsis flex at the top of this one โ€” the whole vibe lives in DESCRIPTION and OPTIONS right underneath. Scroll, queen ๐Ÿ‘‘


๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

Nkf is a yet another kanji code converter among networks, hosts and terminals. Like, it takes your input kanji code and converts it to the designated kanji code โ€” things like ISO-2022-JP, Shift_JIS, EUC-JP, UTF-8, UTF-16 or UTF-32. periodt.

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. it just knows. main character energy fr fr.

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. โœ๏ธ

multiple options are specifed as seprate strings, such as

print nkf('--ic=UTF8-MAC', '-w', $string), "\n";

except the last arguments. (yeah, sneak that last one in there, she's special ๐Ÿ’…)


๐Ÿ‘‘ OPTIONS ๐Ÿ‘‘

๐ŸŽ€ Encodings, in and out

  • -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 โ€” EUC-JP.
    • -W โ€” UTF-8N.
    • -W16[BL][0] โ€” UTF-16. B or L gives whether Big Endian or Little Endian. 0 gives whther put BOM or not.
    • -W32[BL][0] โ€” UTF-32. B or L gives whether Big Endian or Little Endian. 0 gives whther put BOM or not.

๐ŸŒธ Buffering & chill

  • -b, -u โ€” Output is buffered (DEFAULT), Output is unbuffered.
  • -t โ€” No conversion. just vibes, untouched โœจ

๐Ÿงš Escape sequences & friends

  • -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 ๐Ÿ•ต๏ธ

๐Ÿ’… Kana glow-ups

  • -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.

๐Ÿซถ Output modes & folding

  • -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.

๐Ÿ”ฅ Fullwidth alphabet shenanigans

  • -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.

๐ŸŒˆ X0201 kana policy

  • -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.

๐Ÿ’€ Broken-JIS rescue mission

  • -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.

๐ŸŽ€ geta character moment

  • -I โ€” Replacing non iso-2022-jp char into a geta character (substitute character in Japanese).

๐Ÿ“ MIME decode

  • -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 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.

โญ MIME encode

  • -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.

๐Ÿ’œ Latin-1 (with boundaries, bestie)

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

๐Ÿงš Line break control

  • -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. ๐Ÿšจ

โœจ System presets

  • --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

๐ŸŒธ The codeset menu

  • --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-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-16BE-BOM โ€” UTF-16 Big Endian with BOM
    • UTF-16LE โ€” UTF-16 Little Endian without BOM
    • UTF-16LE-BOM โ€” UTF-16 Little Endian with BOM
    • UTF-32 โ€” same as UTF-32BE
    • UTF-32BE โ€” UTF-32 Big Endian without BOM
    • UTF-32BE-BOM โ€” UTF-32 Big Endian with BOM
    • UTF-32LE โ€” UTF-32 Little Endian without BOM
    • UTF-32LE-BOM โ€” UTF-32 Little Endian with BOM

๐Ÿซถ Unassigned characters & byte etiquette

  • --fb-{skip, html, xml, perl, java, subchar} โ€” Specify the way that nkf handles unassigned characters. Without this option, --fb-skip is assumed.
  • --prefix=escape charactertarget 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 opion. ๐Ÿ‘€
  • --cap-input โ€” Decode hex encoded characters.
  • --url-input โ€” Unescape percent escaped characters.
  • --numchar-input โ€” Decode character reference, such as "&#....;".
  • -- โ€” 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 ๐Ÿ’– this was NKF(3pm) from the User Contributed Perl Documentation collection, shipped as perl v5.42.3 on 2026-08-20 โ€” go forth and convert, you absolute icon โœจ๐Ÿ‘‘๐Ÿฆ‹๐ŸŽ€

๐Ÿ“ฆ where this page comes from