{
    "mode": "perldoc",
    "parameter": "NKF",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/NKF/json",
    "generated": "2026-07-05T11:51:53Z",
    "synopsis": "",
    "sections": {
        "NAME": {
            "content": "",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Nkf is a yet another kanji code converter among networks, hosts and terminals. It converts input\nkanji code to designated kanji code such as ISO-2022-JP, ShiftJIS, EUC-JP, UTF-8, UTF-16 or\nUTF-32.\n\nOne of the most unique faculty of nkf is the guess of the input kanji encodings. It currently\nrecognizes ISO-2022-JP, ShiftJIS, EUC-JP, UTF-8, UTF-16 and UTF-32. So users needn't set the\ninput kanji code explicitly.\n\nBy default, X0201 kana is converted into X0208 kana. For X0201 kana, SO/SI, SSO and ESC-(-I\nmethods are supported. For automatic code detection, nkf assumes no X0201 kana in ShiftJIS. To\naccept X0201 in ShiftJIS, use -X, -x or -S.\n\nmultiple options are specifed as seprate strings, such as\n\nprint nkf('--ic=UTF8-MAC', '-w', $string), \"\\n\";\n\nexcept the last arguments.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "-J -S -E -W -W16 -W32 -j -s -e -w -w16 -w32\nSpecify input and output encodings. Upper case is input. cf. --ic and --oc.\n\n-J  ISO-2022-JP (JIS code).\n\n-S  ShiftJIS and JIS X 0201 kana. EUC-JP is recognized as X0201 kana. Without -x flag, JIS\nX 0201 Katakana (a.k.a.halfwidth kana) is converted into JIS X 0208. If you use Windows,\nsee Windows-31J (CP932).\n\n-E  EUC-JP.\n\n-W  UTF-8N.\n\n-W16[BL][0]\nUTF-16. B or L gives whether Big Endian or Little Endian. 0 gives whther put BOM or not.\n\n-W32[BL][0]\nUTF-32. B or L gives whether Big Endian or Little Endian. 0 gives whther put BOM or not.\n\n-b -u\nOutput is buffered (DEFAULT), Output is unbuffered.\n\n-t  No conversion.\n",
            "subsections": [
                {
                    "name": "-i[@B]",
                    "content": "Specify the escape sequence for JIS X 0208.\n\n-i@ Use ESC ( @. (JIS X 0208-1978)\n\n-iB Use ESC ( B. (JIS X 0208-1983/1990 DEFAULT)\n"
                },
                {
                    "name": "-o[BJ]",
                    "content": "Specify the escape sequence for US-ASCII/JIS X 0201 Roman. (DEFAULT B)\n\n-r  {de/en}crypt ROT13/47\n\n-h[123] --hiragana --katakana --katakana-hiragana\n\n-h1 --hiragana\nKatakana to Hiragana conversion.\n\n-h2 --katakana\nHiragana to Katakana conversion.\n\n-h3 --katakana-hiragana\nKatakana to Hiragana and Hiragana to Katakana conversion.\n\n-T  Text mode output (MS-DOS)\n\n-f[*m* [- *n*]]\nFolding on *m* length with *n* margin in a line. Without this option, fold length is 60 and\nfold margin is 10.\n\n-F  New line preserving line folding.\n"
                },
                {
                    "name": "-Z[0-3]",
                    "content": "Convert X0208 alphabet (Fullwidth Alphabets) to ASCII.\n\n-Z -Z0\nConvert X0208 alphabet to ASCII.\n\n-Z1 Convert X0208 kankaku to single ASCII space.\n\n-Z2 Convert X0208 kankaku to double ASCII spaces.\n\n-Z3 Replacing fullwidth >, <, \", & into '&gt;', '&lt;', '&quot;', '&amp;' as in HTML.\n\n-X -x\nWith -X or without this option, X0201 is converted into X0208 Kana. With -x, try to preserve\nX0208 kana and do not convert X0201 kana to X0208. In JIS output, ESC-(-I is used. In EUC\noutput, SS2 is used.\n"
                },
                {
                    "name": "-B[0-2]",
                    "content": "Assume broken JIS-Kanji input, which lost ESC. Useful when your site is using old B-News\nNihongo patch.\n\n-B1 allows any chars after ESC-( or ESC-$.\n\n-B2 force ASCII after NL.\n\n-I  Replacing non iso-2022-jp char into a geta character (substitute character in Japanese).\n"
                },
                {
                    "name": "-m[BQN0]",
                    "content": "MIME ISO-2022-JP/ISO8859-1 decode. (DEFAULT) To see ISO8859-1 (Latin-1) -l is necessary.\n\n-mB Decode MIME base64 encoded stream. Remove header or other part before conversion.\n\n-mQ Decode MIME quoted stream. '' in quoted stream is converted to space.\n\n-mN Non-strict decoding. It allows line break in the middle of the base64 encoding.\n\n-m0 No MIME decode.\n\n-M  MIME encode. Header style. All ASCII code and control characters are intact.\n\n-MB MIME encode Base64 stream. Kanji conversion is performed before encoding, so this cannot\nbe used as a picture encoder.\n\n-MQ Perform quoted encoding.\n\n-l  Input and output code is ISO8859-1 (Latin-1) and ISO-2022-JP. -s, -e and -x are not\ncompatible with this option.\n\n-L[uwm] -d -c\nConvert line breaks.\n\n-Lu -d\nunix (LF)\n\n-Lw -c\nwindows (CRLF)\n\n-Lm mac (CR)\n\nWithout this option, nkf doesn't convert line breaks.\n\n--fj --unix --mac --msdos --windows\nConvert for these systems.\n\n--jis --euc --sjis --mime --base64\nConvert to named code.\n\n--jis-input --euc-input --sjis-input --mime-input --base64-input\nAssume input system\n\n--ic=*input codeset* --oc=*output codeset*\nSet the input or output codeset. NKF supports following codesets and those codeset names are\ncase insensitive.\n\nISO-2022-JP\na.k.a. RFC1468, 7bit JIS, JUNET\n\nEUC-JP (eucJP-nkf)\na.k.a. AT&T JIS, Japanese EUC, UJIS\n\neucJP-ascii\neucJP-ms\nCP51932\nMicrosoft Version of EUC-JP.\n\nShiftJIS\na.k.a. SJIS, MSKanji\n\nWindows-31J\na.k.a. CP932\n\nUTF-8\nsame as UTF-8N\n\nUTF-8N\nUTF-8 without BOM\n\nUTF-8-BOM\nUTF-8 with BOM\n\nUTF8-MAC (input only)\ndecomposed UTF-8\n\nUTF-16\nsame as UTF-16BE\n\nUTF-16BE\nUTF-16 Big Endian without BOM\n\nUTF-16BE-BOM\nUTF-16 Big Endian with BOM\n\nUTF-16LE\nUTF-16 Little Endian without BOM\n\nUTF-16LE-BOM\nUTF-16 Little Endian with BOM\n\nUTF-32\nsame as UTF-32BE\n\nUTF-32BE\nUTF-32 Big Endian without BOM\n\nUTF-32BE-BOM\nUTF-32 Big Endian with BOM\n\nUTF-32LE\nUTF-32 Little Endian without BOM\n\nUTF-32LE-BOM\nUTF-32 Little Endian with BOM\n\n--fb-{skip, html, xml, perl, java, subchar}\nSpecify the way that nkf handles unassigned characters. Without this option, --fb-skip is\nassumed.\n\n--prefix=*escape charactertarget character*..\nWhen nkf converts to ShiftJIS, nkf adds a specified escape character to specified 2nd byte\nof ShiftJIS characters. 1st byte of argument is the escape character and following bytes\nare target characters.\n"
                },
                {
                    "name": "--no-cp932ext",
                    "content": "Handle the characters extended in CP932 as unassigned characters.\n",
                    "long": "--no-cp932ext"
                },
                {
                    "name": "--no-best-fit-chars",
                    "content": "When Unicode to Encoded byte conversion, don't convert characters which is not round trip\nsafe. When Unicode to Unicode conversion, with this and -x option, nkf can be used as UTF\nconverter. (In other words, without this and -x option, nkf doesn't save some characters)\n\nWhen nkf converts strings that related to path, you should use this opion.\n",
                    "long": "--no-best-fit-chars"
                },
                {
                    "name": "--cap-input",
                    "content": "Decode hex encoded characters.\n",
                    "long": "--cap-input"
                },
                {
                    "name": "--url-input",
                    "content": "Unescape percent escaped characters.\n",
                    "long": "--url-input"
                },
                {
                    "name": "--numchar-input",
                    "content": "Decode character reference, such as \"&#....;\".\n\n--  Ignore rest of -option.\n",
                    "long": "--numchar-input"
                }
            ]
        },
        "AUTHOR": {
            "content": "Copyright (c) 1987, Fujitsu LTD. (Itaru ICHIKAWA).\n\nCopyright (c) 1996-2018, The nkf Project.\n",
            "subsections": []
        }
    },
    "flags": [
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "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)"
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "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."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "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."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "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)."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "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. -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. ShiftJIS a.k.a. SJIS, MSKanji 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 --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 ShiftJIS, nkf adds a specified escape character to specified 2nd byte of ShiftJIS characters. 1st byte of argument is the escape character and following bytes are target characters."
        },
        {
            "flag": "",
            "long": "--no-cp932ext",
            "arg": null,
            "description": "Handle the characters extended in CP932 as unassigned characters."
        },
        {
            "flag": "",
            "long": "--no-best-fit-chars",
            "arg": null,
            "description": "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."
        },
        {
            "flag": "",
            "long": "--cap-input",
            "arg": null,
            "description": "Decode hex encoded characters."
        },
        {
            "flag": "",
            "long": "--url-input",
            "arg": null,
            "description": "Unescape percent escaped characters."
        },
        {
            "flag": "",
            "long": "--numchar-input",
            "arg": null,
            "description": "Decode character reference, such as \"&#....;\". -- Ignore rest of -option."
        }
    ],
    "examples": [],
    "see_also": []
}